aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/src/Text/Edifact/Common/Segments
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Text/Edifact/Common/Segments')
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNA.hs34
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNB.hs63
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNH.hs44
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNS.hs27
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNT.hs30
-rw-r--r--core/src/Text/Edifact/Common/Segments/UNZ.hs24
6 files changed, 222 insertions, 0 deletions
diff --git a/core/src/Text/Edifact/Common/Segments/UNA.hs b/core/src/Text/Edifact/Common/Segments/UNA.hs
new file mode 100644
index 0000000..1b20a9f
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNA.hs
@@ -0,0 +1,34 @@
1module Text.Edifact.Common.Segments.UNA
2 ( segmentUNA
3 ) where
4
5import Text.Edifact.Parsing
6import Text.Edifact.Parsing.Commons (updateSyntax)
7import Text.Edifact.Types (Syntax (..), defaultSyntax)
8
9import Control.Monad (void)
10import Text.Parsec (anyChar, char, endOfLine,
11 optionMaybe, string, try)
12import qualified Text.Parsec as P (optional)
13
14segmentUNA :: Parser ()
15segmentUNA =
16 let segmentParser = string "UNA" *> parseSyntax <* P.optional endOfLine
17 nothing = pure ()
18 in optionMaybe (try segmentParser) >>= maybe nothing updateSyntax
19
20parseSyntax :: Parser Syntax
21parseSyntax = do
22 compositeSeparator' <- anyChar
23 elementSeparator' <- anyChar
24 decimalSign' <- anyChar
25 escape' <- anyChar
26 void $ char ' ' -- reserved, not used
27 segmentSeparator' <- anyChar
28 pure defaultSyntax
29 { compositeSeparator = compositeSeparator'
30 , elementSeparator = elementSeparator'
31 , decimalSign = decimalSign'
32 , escape = escape'
33 , segmentSeparator = segmentSeparator'
34 }
diff --git a/core/src/Text/Edifact/Common/Segments/UNB.hs b/core/src/Text/Edifact/Common/Segments/UNB.hs
new file mode 100644
index 0000000..55f1eea
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNB.hs
@@ -0,0 +1,63 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Common.Segments.UNB
4 ( segmentUNB
5 ) where
6
7import Text.Edifact.Common.Composites (compositeS001, compositeS002,
8 compositeS003, compositeS004,
9 compositeS005)
10import Text.Edifact.Common.Simples (simple0020, simple0026,
11 simple0029, simple0031,
12 simple0032, simple0035)
13
14import Text.Edifact.Parsing
15import Text.Edifact.Types (Value)
16
17-- | Derived from this specification:
18--
19-- > Pos Segment M/C Repeat Repr. Notes
20-- > 010 S001 SYNTAX IDENTIFIER M 1
21-- > 0001 Syntax identifier M a4
22-- > 0002 Syntax version number M an1
23-- > 0080 Service code list directory version number C an..6
24-- > 0133 Character encoding, coded C an..3
25-- > 020 S002 INTERCHANGE SENDER M 1
26-- > 0004 Interchange sender identification M an..35
27-- > 0007 Identification code qualifier C an..4
28-- > 0008 Interchange sender internal identification C an..35
29-- > 0042 Interchange sender internal sub-identification C an..35
30-- > 030 S003 INTERCHANGE RECIPIENT M 1
31-- > 0010 Interchange recipient identification M an..35
32-- > 0007 Identification code qualifier C an..4
33-- > 0014 Interchange recipient internal identification C an..35
34-- > 0046 Interchange recipient internal sub-identification C an..35
35-- > 040 S004 DATE AND TIME OF PREPARATION M 1
36-- > 0017 Date M n8
37-- > 0019 Time M n4
38-- > 050 0020 Interchange control reference M 1 an..14
39-- > 060 S005 RECIPIENT'S REFERENCE/PASSWORD DETAILS C 1
40-- > 0022 Recipient reference/password M an..14
41-- > 0025 Recipient reference/password qualifier C an2
42-- > 070 0026 Application reference C 1 an..14
43-- > 080 0029 Processing priority code C 1 a1
44-- > 090 0031 Acknowledgement request C 1 n1
45-- > 100 0032 Interchange agreement identifier C 1 an..35
46-- > 110 0035 Test indicator C 1 n1
47--
48-- Dependencies: 'compositeS001', 'compositeS002', 'compositeS003', 'compositeS004', 'compositeS005', 'simple0020', 'simple0026', 'simple0029', 'simple0031', 'simple0032', 'simple0035'.
49segmentUNB :: Parser Value
50segmentUNB =
51 segment "UNB"
52 [ "010" .@ mandatory compositeS001
53 , "020" .@ mandatory compositeS002
54 , "030" .@ mandatory compositeS003
55 , "040" .@ mandatory compositeS004
56 , "050" .@ mandatory simple0020
57 , "060" .@ optional compositeS005
58 , "070" .@ optional simple0026
59 , "080" .@ optional simple0029
60 , "090" .@ optional simple0031
61 , "100" .@ optional simple0032
62 , "110" .@ optional simple0035
63 ]
diff --git a/core/src/Text/Edifact/Common/Segments/UNH.hs b/core/src/Text/Edifact/Common/Segments/UNH.hs
new file mode 100644
index 0000000..61cb6b3
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNH.hs
@@ -0,0 +1,44 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Common.Segments.UNH
4 ( segmentUNH
5 ) where
6
7import Text.Edifact.Common.Composites (compositeS009, compositeS010)
8import Text.Edifact.Common.Simples (simple0062, simple0068)
9
10import Text.Edifact.Parsing
11import Text.Edifact.Types (Value)
12
13-- | Derived from this specification:
14--
15-- > Change indicators
16-- >
17-- > UNH MESSAGE HEADER
18-- >
19-- > Function: To head, identify and specify a message.
20-- >
21-- > 010 0062 MESSAGE REFERENCE NUMBER M an..14
22-- >
23-- > 020 S009 MESSAGE IDENTIFIER M
24-- > 0065 Message type M an..6
25-- > 0052 Message version number M an..3
26-- > 0054 Message release number M an..3
27-- > 0051 Controlling agency M an..2
28-- > 0057 Association assigned code C an..6
29-- >
30-- > 030 0068 COMMON ACCESS REFERENCE C an..35
31-- >
32-- > 040 S010 STATUS OF THE TRANSFER C
33-- > 0070 Sequence of transfers M n..2
34-- > 0073 First and last transfer C a1
35--
36-- Dependencies: 'compositeS009', 'compositeS010', 'simple0062', 'simple0068'.
37segmentUNH :: Parser Value
38segmentUNH =
39 segment "UNH"
40 [ "010" .@ mandatory simple0062
41 , "020" .@ mandatory compositeS009
42 , "030" .@ optional simple0068
43 , "040" .@ optional compositeS010
44 ]
diff --git a/core/src/Text/Edifact/Common/Segments/UNS.hs b/core/src/Text/Edifact/Common/Segments/UNS.hs
new file mode 100644
index 0000000..3d9b395
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNS.hs
@@ -0,0 +1,27 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Common.Segments.UNS
4 ( segmentUNS
5 ) where
6
7import Text.Edifact.Common.Simples (simple0081)
8
9import Text.Edifact.Parsing
10import Text.Edifact.Types (Value)
11
12-- | Derived from this specification:
13--
14-- > Change indicators
15-- >
16-- > UNS SECTION CONTROL
17-- >
18-- > Function: To separate Header, Detail and Summary sections of a message
19-- >
20-- > 010 0081 SECTION IDENTIFICATION M a1
21--
22-- Dependencies: 'simple0081'.
23segmentUNS :: Parser Value
24segmentUNS =
25 segment "UNS"
26 [ "010" .@ mandatory simple0081
27 ]
diff --git a/core/src/Text/Edifact/Common/Segments/UNT.hs b/core/src/Text/Edifact/Common/Segments/UNT.hs
new file mode 100644
index 0000000..e91f9cf
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNT.hs
@@ -0,0 +1,30 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Common.Segments.UNT
4 ( segmentUNT
5 ) where
6
7import Text.Edifact.Common.Simples (simple0062, simple0074)
8
9import Text.Edifact.Parsing
10import Text.Edifact.Types (Value)
11
12-- | Derived from this specification:
13--
14-- > Change indicators
15-- >
16-- > UNT MESSAGE TRAILER
17-- >
18-- > Function: To end and check the completeness of a message.
19-- >
20-- > 010 0074 NUMBER OF SEGMENTS IN THE MESSAGE M n..6
21-- >
22-- > 020 0062 MESSAGE REFERENCE NUMBER M an..14
23--
24-- Dependencies: 'simple0062', 'simple0074'.
25segmentUNT :: Parser Value
26segmentUNT =
27 segment "UNT"
28 [ "010" .@ mandatory simple0074
29 , "020" .@ mandatory simple0062
30 ]
diff --git a/core/src/Text/Edifact/Common/Segments/UNZ.hs b/core/src/Text/Edifact/Common/Segments/UNZ.hs
new file mode 100644
index 0000000..0566860
--- /dev/null
+++ b/core/src/Text/Edifact/Common/Segments/UNZ.hs
@@ -0,0 +1,24 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Common.Segments.UNZ
4 ( segmentUNZ
5 ) where
6
7import Text.Edifact.Common.Simples (simple0020, simple0036)
8
9import Text.Edifact.Parsing
10import Text.Edifact.Types (Value)
11
12-- | Derived from this specification:
13--
14-- > Pos Segment M/C Repeat Repr. Notes
15-- > 010 0036 Interchange control count M 1 n..6
16-- > 020 0020 Interchange control reference M 1 an..14
17--
18-- Dependencies: 'simple0020', 'simple0036'.
19segmentUNZ :: Parser Value
20segmentUNZ =
21 segment "UNZ"
22 [ "010" .@ mandatory simple0036
23 , "030" .@ mandatory simple0020
24 ]