diff options
Diffstat (limited to 'scaffolder/src/Text/Edifact/Scaffolder/Simples.hs')
-rw-r--r-- | scaffolder/src/Text/Edifact/Scaffolder/Simples.hs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scaffolder/src/Text/Edifact/Scaffolder/Simples.hs b/scaffolder/src/Text/Edifact/Scaffolder/Simples.hs new file mode 100644 index 0000000..95885c2 --- /dev/null +++ b/scaffolder/src/Text/Edifact/Scaffolder/Simples.hs | |||
@@ -0,0 +1,41 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | |||
3 | module Text.Edifact.Scaffolder.Simples | ||
4 | ( simples | ||
5 | ) where | ||
6 | |||
7 | import Text.Edifact.Scaffolder.Commons | ||
8 | |||
9 | import Text.Edifact.Scaffolder.Simples.Elements | ||
10 | import Text.Edifact.Scaffolder.Simples.Implementation | ||
11 | import Text.Edifact.Scaffolder.Simples.Representation | ||
12 | |||
13 | import Formatting | ||
14 | |||
15 | simples :: Scaffolding () | ||
16 | simples = listSimples >>= scaffoldElements parentSimpleModule simpleModule | ||
17 | |||
18 | parentSimpleModule :: NonEmpty (ElementWithDefinition SimpleCode) -> Scaffolding () | ||
19 | parentSimpleModule = parentModule "Simples" "S" simpleModuleName | ||
20 | |||
21 | simpleModuleName :: ModuleName -> SimpleCode -> ModuleName | ||
22 | simpleModuleName mn code = mn <.> fromString ("S" <> getSimpleCode code) | ||
23 | |||
24 | simpleModule :: ElementWithDefinition SimpleCode -> Scaffolding () | ||
25 | simpleModule (inputFile, code) = do | ||
26 | moduleName <- getRootModuleNameFor (simpleModuleName "Simples" code) | ||
27 | representation <- extractRepresentation inputFile | ||
28 | specification <- includeSpecification inputFile | ||
29 | let parserFunction = fSimpleParserFunction | ||
30 | fDescription = "Simple " % fSimpleCode | ||
31 | defaultImplementation = sformat (notYetImplemented fDescription) code | ||
32 | implementation = maybe defaultImplementation toImplementation representation | ||
33 | exports = [ Name (sformat parserFunction code) ] | ||
34 | imports = importCombinators | ||
35 | : maybe [importNotYetImplementedHelper] (const []) representation | ||
36 | documentation = specification | ||
37 | signature = sformat (fParserSignature parserFunction) code | ||
38 | definition = [ sformat (fParserDeclaration parserFunction % " simple " % quoted fSimpleCode % " " % parens stext) code code implementation | ||
39 | ] | ||
40 | parser = signature : definition | ||
41 | scaffoldModule moduleName ["OverloadedStrings"] exports imports (documentation <> parser) | ||