1 {-# LANGUAGE DerivingStrategies #-}
2 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
4 module Text.Edifact.Scaffolder.Messages.Types where
6 import Text.Edifact.Scaffolder.Commons
8 import Data.Function (on)
9 import Data.Ord (comparing)
11 newtype Dependency = Dependency { getElement :: Element } deriving newtype (Show, Ord, Eq)
13 data Repetition = Repetition Presence Cardinality deriving Show
15 data Positional = Positional { positionalPosition :: Position
16 , positionalRepetition :: Repetition
19 instance Eq Positional where
20 (==) = (==) `on` positionalPosition
22 instance Ord Positional where
23 compare = comparing positionalPosition
25 data Element = Segment SegmentCode Positional
26 | GroupStart GroupCode Positional
28 deriving (Show, Ord, Eq)
30 getSegment :: Element -> Maybe SegmentCode
31 getSegment (Segment code _) = Just code
32 getSegment _ = Nothing
34 newtype Cardinality = Cardinality { getCardinality :: Int }
36 deriving newtype (Eq, Num)