1 {-# LANGUAGE OverloadedStrings #-}
3 module Text.Edifact.Scaffolder.Commons.Formatters
6 , fMessageParserFunction
9 , fSegmentParserFunction
11 , fCompositeParserFunction
13 , fSimpleParserFunction
29 import Text.Edifact.Scaffolder.Commons.Types
31 import Formatting as F
33 fMessageCode:: Format r (MessageCode -> r)
34 fMessageCode = mapf getMessageCode F.string
36 fMessageParserFunction :: Format r (MessageCode -> r)
37 fMessageParserFunction = mapf getMessageCode ("message" % F.string)
39 fGroupCode :: Format r (GroupCode -> r)
40 fGroupCode = mapf getGroupCode F.string
42 fSegmentCode :: Format r (SegmentCode -> r)
43 fSegmentCode = mapf getSegmentCode F.string
45 fSegmentParserFunction :: Format r (SegmentCode -> r)
46 fSegmentParserFunction = mapf getSegmentCode ("segment" % F.string)
48 fCompositeCode :: Format r (CompositeCode -> r)
49 fCompositeCode = mapf getCompositeCode F.string
51 fCompositeParserFunction :: Format r (CompositeCode -> r)
52 fCompositeParserFunction = mapf getCompositeCode ("composite" % F.string)
54 fSimpleCode :: Format r (SimpleCode -> r)
55 fSimpleCode = mapf getSimpleCode F.string
57 fSimpleParserFunction :: Format r (SimpleCode -> r)
58 fSimpleParserFunction = mapf getSimpleCode ("simple" % F.string)
60 fParserSignature :: Format r a -> Format r a
61 fParserSignature f = f % " :: Parser Value"
63 fParserDeclaration :: Format r a -> Format r a
64 fParserDeclaration f = f % " ="
66 fModuleName :: Format r (ModuleName -> r)
67 fModuleName = mapf getModuleName string
69 fPosition :: Format r (Position -> r)
70 fPosition = mapf getPosition F.string
72 fPresence :: Format r (Presence -> r)
74 let f Mandatory = "mandatory"
75 f Optional = "optional "
78 quoted :: Format r a -> Format r a
79 quoted f = "\"" % f % "\""
81 simpleQuoted :: Format r a -> Format r a
82 simpleQuoted f = "'" % f % "'"
84 parens :: Format r a -> Format r a
85 parens f = "(" % f % ")"
87 notYetImplemented :: Format r a -> Format r a
88 notYetImplemented desc = "notYetImplemented " % quoted (desc % " not yet implemented")