aboutsummaryrefslogtreecommitdiffhomepage
path: root/scaffolder/src/Text/Edifact/Scaffolder/Simples/Implementation.hs
blob: 6cfb2ab581f1326e882f6bb10b7a3dcff5ac691c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE OverloadedStrings #-}

module Text.Edifact.Scaffolder.Simples.Implementation
  ( -- *
    toImplementation
  ) where

import           Text.Edifact.Scaffolder.Commons
import           Text.Edifact.Scaffolder.Simples.Types

import           Formatting

toImplementation :: Representation -> Text
toImplementation (Representation content (UpTo n)   ) = sformat (fContent % " `upTo` " % int) content n
toImplementation (Representation content (Exactly n)) = sformat (fContent % " `exactly` " % int) content n
toImplementation (Representation content AnyNumber  ) = sformat ("many " % fContent) content

fContent :: Format t (Content -> t)
fContent =
  let display AlphaNumeric = "alphaNumeric"
      display Alpha        = "alpha"
      display Numeric      = "numeric"
  in mapf display stext