blob: 73cc7023a44e960f1b259aa5c70910f769c134a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Text.Edifact.Scaffolder.Messages.Types where
import Text.Edifact.Scaffolder.Commons
import Data.Function (on)
import Data.Ord (comparing)
newtype Dependency = Dependency { getElement :: Element } deriving newtype (Show, Ord, Eq)
data Repetition = Repetition Presence Cardinality deriving Show
data Positional = Positional { positionalPosition :: Position
, positionalRepetition :: Repetition
} deriving (Show)
instance Eq Positional where
(==) = (==) `on` positionalPosition
instance Ord Positional where
compare = comparing positionalPosition
data Element = Segment SegmentCode Positional
| GroupStart GroupCode Positional
| GroupEnd GroupCode
deriving (Show, Ord, Eq)
getSegment :: Element -> Maybe SegmentCode
getSegment (Segment code _) = Just code
getSegment _ = Nothing
newtype Cardinality = Cardinality { getCardinality :: Int }
deriving stock (Show)
deriving newtype (Eq, Num)
|