]>
Commit | Line | Data |
---|---|---|
a9d77a20 FM |
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) |