aboutsummaryrefslogtreecommitdiffhomepage
path: root/scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs
diff options
context:
space:
mode:
Diffstat (limited to 'scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs')
-rw-r--r--scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs88
1 files changed, 88 insertions, 0 deletions
diff --git a/scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs b/scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs
new file mode 100644
index 0000000..6f0210b
--- /dev/null
+++ b/scaffolder/src/Text/Edifact/Scaffolder/Commons/Formatters.hs
@@ -0,0 +1,88 @@
1{-# LANGUAGE OverloadedStrings #-}
2
3module Text.Edifact.Scaffolder.Commons.Formatters
4 ( -- *
5 fMessageCode
6 , fMessageParserFunction
7 , fGroupCode
8 , fSegmentCode
9 , fSegmentParserFunction
10 , fCompositeCode
11 , fCompositeParserFunction
12 , fSimpleCode
13 , fSimpleParserFunction
14
15 -- *
16 , fParserSignature
17 , fParserDeclaration
18 -- *
19 , fModuleName
20 , fPosition
21 , fPresence
22 -- *
23 , quoted
24 , simpleQuoted
25 , parens
26 , notYetImplemented
27 ) where
28
29import Text.Edifact.Scaffolder.Commons.Types
30
31import Formatting as F
32
33fMessageCode:: Format r (MessageCode -> r)
34fMessageCode = mapf getMessageCode F.string
35
36fMessageParserFunction :: Format r (MessageCode -> r)
37fMessageParserFunction = mapf getMessageCode ("message" % F.string)
38
39fGroupCode :: Format r (GroupCode -> r)
40fGroupCode = mapf getGroupCode F.string
41
42fSegmentCode :: Format r (SegmentCode -> r)
43fSegmentCode = mapf getSegmentCode F.string
44
45fSegmentParserFunction :: Format r (SegmentCode -> r)
46fSegmentParserFunction = mapf getSegmentCode ("segment" % F.string)
47
48fCompositeCode :: Format r (CompositeCode -> r)
49fCompositeCode = mapf getCompositeCode F.string
50
51fCompositeParserFunction :: Format r (CompositeCode -> r)
52fCompositeParserFunction = mapf getCompositeCode ("composite" % F.string)
53
54fSimpleCode :: Format r (SimpleCode -> r)
55fSimpleCode = mapf getSimpleCode F.string
56
57fSimpleParserFunction :: Format r (SimpleCode -> r)
58fSimpleParserFunction = mapf getSimpleCode ("simple" % F.string)
59
60fParserSignature :: Format r a -> Format r a
61fParserSignature f = f % " :: Parser Value"
62
63fParserDeclaration :: Format r a -> Format r a
64fParserDeclaration f = f % " ="
65
66fModuleName :: Format r (ModuleName -> r)
67fModuleName = mapf getModuleName string
68
69fPosition :: Format r (Position -> r)
70fPosition = mapf getPosition F.string
71
72fPresence :: Format r (Presence -> r)
73fPresence =
74 let f Mandatory = "mandatory"
75 f Optional = "optional "
76 in mapf f F.string
77
78quoted :: Format r a -> Format r a
79quoted f = "\"" % f % "\""
80
81simpleQuoted :: Format r a -> Format r a
82simpleQuoted f = "'" % f % "'"
83
84parens :: Format r a -> Format r a
85parens f = "(" % f % ")"
86
87notYetImplemented :: Format r a -> Format r a
88notYetImplemented desc = "notYetImplemented " % quoted (desc % " not yet implemented")