]> git.immae.eu Git - github/fretlink/edi-parser.git/blame - scaffolder/src/Text/Edifact/Scaffolder/Messages/Types.hs
Release code as open source
[github/fretlink/edi-parser.git] / scaffolder / src / Text / Edifact / Scaffolder / Messages / Types.hs
CommitLineData
a9d77a20
FM
1{-# LANGUAGE DerivingStrategies #-}
2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3
4module Text.Edifact.Scaffolder.Messages.Types where
5
6import Text.Edifact.Scaffolder.Commons
7
8import Data.Function (on)
9import Data.Ord (comparing)
10
11newtype Dependency = Dependency { getElement :: Element } deriving newtype (Show, Ord, Eq)
12
13data Repetition = Repetition Presence Cardinality deriving Show
14
15data Positional = Positional { positionalPosition :: Position
16 , positionalRepetition :: Repetition
17 } deriving (Show)
18
19instance Eq Positional where
20 (==) = (==) `on` positionalPosition
21
22instance Ord Positional where
23 compare = comparing positionalPosition
24
25data Element = Segment SegmentCode Positional
26 | GroupStart GroupCode Positional
27 | GroupEnd GroupCode
28 deriving (Show, Ord, Eq)
29
30getSegment :: Element -> Maybe SegmentCode
31getSegment (Segment code _) = Just code
32getSegment _ = Nothing
33
34newtype Cardinality = Cardinality { getCardinality :: Int }
35 deriving stock (Show)
36 deriving newtype (Eq, Num)