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