diff options
Diffstat (limited to 'scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs')
-rw-r--r-- | scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs b/scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs new file mode 100644 index 0000000..73cc702 --- /dev/null +++ b/scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs | |||
@@ -0,0 +1,36 @@ | |||
1 | {-# LANGUAGE DerivingStrategies #-} | ||
2 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
3 | |||
4 | module Text.Edifact.Scaffolder.Messages.Types where | ||
5 | |||
6 | import Text.Edifact.Scaffolder.Commons | ||
7 | |||
8 | import Data.Function (on) | ||
9 | import Data.Ord (comparing) | ||
10 | |||
11 | newtype Dependency = Dependency { getElement :: Element } deriving newtype (Show, Ord, Eq) | ||
12 | |||
13 | data Repetition = Repetition Presence Cardinality deriving Show | ||
14 | |||
15 | data Positional = Positional { positionalPosition :: Position | ||
16 | , positionalRepetition :: Repetition | ||
17 | } deriving (Show) | ||
18 | |||
19 | instance Eq Positional where | ||
20 | (==) = (==) `on` positionalPosition | ||
21 | |||
22 | instance Ord Positional where | ||
23 | compare = comparing positionalPosition | ||
24 | |||
25 | data Element = Segment SegmentCode Positional | ||
26 | | GroupStart GroupCode Positional | ||
27 | | GroupEnd GroupCode | ||
28 | deriving (Show, Ord, Eq) | ||
29 | |||
30 | getSegment :: Element -> Maybe SegmentCode | ||
31 | getSegment (Segment code _) = Just code | ||
32 | getSegment _ = Nothing | ||
33 | |||
34 | newtype Cardinality = Cardinality { getCardinality :: Int } | ||
35 | deriving stock (Show) | ||
36 | deriving newtype (Eq, Num) | ||