diff options
author | Frédéric Menou <frederic.menou@fretlink.com> | 2016-12-08 10:19:15 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2022-05-17 18:01:51 +0200 |
commit | a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 (patch) | |
tree | adf3186fdccaeef19151026cdfbd38a530cf9ecb /scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs | |
download | edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.gz edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.zst edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.zip |
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) | ||