on develop help sign in
Generating help and module exports
20e9832Brendan Hay
gen/annex/compute.json+1
@@ -1,3 +1,4 @@
1{
1{
2+ "library": "gozen-compute"
2}
3}
3
4
gen/gozen-gen.cabal+2
@@ -25,6 +25,7 @@ executable gozen-gen
25 , Gen.Formatting
25 , Gen.Formatting
26 , Gen.IO
26 , Gen.IO
27 , Gen.JSON
27 , Gen.JSON
28+ , Gen.Solve
28 , Gen.Syntax
29 , Gen.Syntax
29 , Gen.Text
30 , Gen.Text
30 , Gen.Tree
31 , Gen.Tree
@@ -50,6 +51,7 @@ executable gozen-gen
50 , lens
51 , lens
51 , mtl
52 , mtl
52 , optparse-applicative
53 , optparse-applicative
54+ , pandoc
53 , parsec
55 , parsec
54 , semigroups
56 , semigroups
55 , system-fileio
57 , system-fileio
gen/src/Gen/AST.hs+18−12
@@ -33,6 +33,7 @@ import Data.List.NonEmpty (NonEmpty (..))
33import Data.Semigroup ((<>))
33import Data.Semigroup ((<>))
34import qualified Data.Text.Lazy as LText
34import qualified Data.Text.Lazy as LText
35import qualified Data.Text.Lazy.Builder as Build
35import qualified Data.Text.Lazy.Builder as Build
36+import Gen.Formatting
36import Gen.Solve
37import Gen.Solve
37import Gen.Syntax
38import Gen.Syntax
38import Gen.Text
39import Gen.Text
@@ -94,29 +95,34 @@ render s = runAST (Memo mempty mempty ss) $ do
94
95
95 go :: Id -> Schema Id -> AST (Maybe Data)
96 go :: Id -> Schema Id -> AST (Maybe Data)
96 go k = \case
97 go k = \case
97− Arr {} -> pure Nothing
98+ Arr {} -> pure Nothing
98− Ref {} -> pure Nothing
99+ Ref {} -> pure Nothing
99− Any {} -> pure Nothing
100+ Any {} -> pure Nothing
100− Lit {} -> pure Nothing
101+ Lit {} -> pure Nothing
101− Enum {} -> Just <$> sum
102+ Enum i _ _ -> Just <$> sum
102 where
103 where
103− sum = Sum "sum help"
104+ sum = Sum (dname k) (i ^. description)
104 <$> pp Indent enumDecl
105 <$> pp Indent enumDecl
105
106
106− Obj _ rs -> Just <$> (traverse solve rs >>= prod)
107+ Obj i rs -> Just <$> (traverse solve rs >>= prod)
107 where
108 where
108− prod ts = Prod
109+ prod ts = Prod (dname k) (i ^. description)
109 <$> (objDecl k ts >>= pp Indent)
110 <$> (objDecl k ts >>= pp Indent)
110 <*> ctor ts
111 <*> ctor ts
111 <*> traverse (uncurry lens) (Map.toList ts)
112 <*> traverse (uncurry lens) (Map.toList ts)
112
113
113− ctor ts = Fun' "ctor help"
114+ ctor ts = Fun' (cname k) (Just help)
114 <$> (pp None (ctorSig k ts) >>= comments ts)
115 <$> (pp None (ctorSig k ts) >>= comments ts)
115 <*> pp Indent (ctorDecl k ts)
116 <*> pp Indent (ctorDecl k ts)
116
117
117− lens _ _ = Fun' "lens help"
118+ lens n v = Fun' (lname n) (v ^. description)
118− <$> pp None lensSig
119+ <$> pp None (lensSig k n v)
119− <*> pp Print lensDecl
120+ <*> pp Print (lensDecl n v)
121+
122+ help = rawHelpText $
123+ sformat ("Creates a value of '" % fid %
124+ "' with the minimum fields required to make a request.\n")
125+ k
120
126
121data PP
127data PP
122 = Indent
128 = Indent
gen/src/Gen/Solve.hs+7−6
@@ -26,6 +26,7 @@ import Control.Monad.Except
26import Control.Monad.State
26import Control.Monad.State
27import qualified Data.HashMap.Strict as Map
27import qualified Data.HashMap.Strict as Map
28import Data.List (intersect)
28import Data.List (intersect)
29+import Data.Maybe
29import Data.Semigroup ((<>))
30import Data.Semigroup ((<>))
30import Gen.Formatting
31import Gen.Formatting
31import Gen.Types
32import Gen.Types
@@ -109,11 +110,12 @@ typeOf k = loc "typeOf" k $ memo typed k go
109 Arr _ r -> TList <$> typeOf r
110 Arr _ r -> TList <$> typeOf r
110 Enum {} -> pure (TType k)
111 Enum {} -> pure (TType k)
111 Ref _ r -> typeOf r
112 Ref _ r -> typeOf r
112− Any {} -> pure (TEither (TLit Text) (TLit Long))
113+ Any {} -> pure (TEither (TLit Text) (TLit Int64))
113 Lit _ l -> pure (TLit l)
114 Lit _ l -> pure (TLit l)
114 where
115 where
115− may | parameter s = id
116+ may | s ^. required = id
117+ | isJust (s ^. defaulted) = id
116− | otherwise = TMaybe
118+ | otherwise = TMaybe
117
119
118derive :: Id -> AST [Derive]
120derive :: Id -> AST [Derive]
119derive k = loc "derive" k $ memo derived k go
121derive k = loc "derive" k $ memo derived k go
@@ -128,10 +130,9 @@ derive k = loc "derive" k $ memo derived k go
128 case l of
130 case l of
129 Text -> base <> [DOrd, DIsString]
131 Text -> base <> [DOrd, DIsString]
130 Bool -> base <> enum
132 Bool -> base <> enum
131− Int -> base
132− Long -> base <> [DNum, DIntegral, DReal] <> enum
133− Nat -> base
134 Time -> base
133 Time -> base
134+ Nat -> base
135+ _ -> base <> [DNum, DIntegral, DReal] <> enum
135
136
136 props ds x = intersect ds <$> derive x
137 props ds x = intersect ds <$> derive x
137
138
gen/src/Gen/Syntax.hs+62−13
@@ -2,6 +2,8 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE TupleSections #-}
3{-# LANGUAGE TupleSections #-}
4
4
5+{-# OPTIONS_GHC -fno-warn-orphans #-}
6+
5-- Module : Gen.Syntax
7-- Module : Gen.Syntax
6-- Copyright : (c) 2015 Brendan Hay
8-- Copyright : (c) 2015 Brendan Hay
7-- License : Mozilla Public License, v. 2.0.
9-- License : Mozilla Public License, v. 2.0.
@@ -11,9 +13,11 @@
11
13
12module Gen.Syntax where
14module Gen.Syntax where
13
15
14−import Control.Lens hiding (strict)
16+import Control.Lens hiding (iso, mapping, op, strict)
15import Data.Foldable (foldr')
17import Data.Foldable (foldr')
16import qualified Data.HashMap.Strict as Map
18import qualified Data.HashMap.Strict as Map
19+import Data.Maybe
20+import Data.String
17import Data.Text (Text)
21import Data.Text (Text)
18import qualified Data.Text as Text
22import qualified Data.Text as Text
19import Data.Text.Manipulate
23import Data.Text.Manipulate
@@ -24,6 +28,12 @@ import Language.Haskell.Exts.Build
24import Language.Haskell.Exts.SrcLoc
28import Language.Haskell.Exts.SrcLoc
25import Language.Haskell.Exts.Syntax hiding (Int)
29import Language.Haskell.Exts.Syntax hiding (Int)
26
30
31+instance IsString Name where
32+ fromString = name
33+
34+instance IsString QOp where
35+ fromString = op . name
36+
27objDecl :: Id -> Map Id Solved -> AST Decl
37objDecl :: Id -> Map Id Solved -> AST Decl
28objDecl r rs = DataDecl noLoc arity [] d [] [conDecl d rs] <$> derivings r
38objDecl r rs = DataDecl noLoc arity [] d [] [conDecl d rs] <$> derivings r
29 where
39 where
@@ -66,15 +76,29 @@ ctorDecl r rs = sfun noLoc c ps (UnGuardedRhs rhs) noBinds
66fieldUpdate :: Id -> Solved -> FieldUpdate
76fieldUpdate :: Id -> Solved -> FieldUpdate
67fieldUpdate r s = FieldUpdate (UnQual (fname r)) rhs
77fieldUpdate r s = FieldUpdate (UnQual (fname r)) rhs
68 where
78 where
79+ rhs | s ^. required = p
69− rhs | Just x <- s ^. defaulted = str x
80+ | Just x <- s ^. defaulted = str x
70− | s ^. required = var (pname r)
81+ | Just v <- iso (_type s) = infixApp v "#" p
71 | otherwise = var (name "Nothing")
82 | otherwise = var (name "Nothing")
72
83
84+ p = var (pname r)
85+
73−lensSig :: Decl
86+lensSig :: Id -> Id -> Solved -> Decl
74−lensSig = emptyDecl
87+lensSig n r s = TypeSig noLoc [lname r] $
88+ TyApp (TyApp (tycon "Lens'") (tycon n))
89+ (external (_type s))
90+
91+lensDecl :: Id -> Solved -> Decl
92+lensDecl r s = sfun noLoc l [] (UnGuardedRhs rhs) noBinds
93+ where
94+ l = lname r
95+ f = fname r
96+ t = _type s
75
97
76−lensDecl :: Decl
98+ rhs = mapping t $
77−lensDecl = emptyDecl
99+ app (app (var "lens") (var f))
100+ (paren (lamE noLoc [pvar "s", pvar "a"]
101+ (RecUpdate (var "s") [FieldUpdate (UnQual f) (var "a")])))
78
102
79enumDecl :: Decl
103enumDecl :: Decl
80enumDecl = emptyDecl
104enumDecl = emptyDecl
@@ -100,12 +124,33 @@ internal = go
100 TLit l -> lit l
124 TLit l -> lit l
101
125
102 lit = \case
126 lit = \case
103− Text -> tycon "Text"
127+ Text -> tycon "Text"
104− Bool -> tycon "Bool"
128+ Bool -> tycon "Bool"
105− Int -> tycon "Int"
106− Long -> tycon "Integer"
107− Nat -> tycon "Natural"
108− Time -> tycon "UTCTime"
129+ Time -> tycon "UTCTime"
130+ Nat -> tycon "Natural"
131+ Float -> tycon "Float"
132+ Double -> tycon "Double"
133+ Byte -> tycon "Word8"
134+ UInt32 -> tycon "Word32"
135+ UInt64 -> tycon "Word64"
136+ Int32 -> tycon "Int32"
137+ Int64 -> tycon "Int64"
138+
139+mapping :: TType -> Exp -> Exp
140+mapping t e = infixE e "." (go t)
141+ where
142+ go = \case
143+ TMaybe x@(TList {}) -> var "_Default" : go x
144+ TMaybe x -> nest (go x)
145+ x -> maybeToList (iso x)
146+
147+ nest [] = []
148+ nest (x:xs) = [app (var "mapping") (infixE x "." xs)]
149+
150+iso :: TType -> Maybe Exp
151+iso = \case
152+ TList {} -> Just (var "_Coerce")
153+ _ -> Nothing
109
154
110strict :: Type -> Type
155strict :: Type -> Type
111strict = TyBang BangedTy . \case
156strict = TyBang BangedTy . \case
@@ -128,5 +173,9 @@ ref f = Text.unpack . f . idToText
128unqual :: String -> QName
173unqual :: String -> QName
129unqual = UnQual . name
174unqual = UnQual . name
130
175
176+infixE :: Exp -> QOp -> [Exp] -> Exp
177+infixE l _ [] = l
178+infixE l o (r:rs) = infixE (infixApp l o r) o rs
179+
131str :: Text -> Exp
180str :: Text -> Exp
132str = strE . Text.unpack
181str = strE . Text.unpack
gen/src/Gen/Types.hs+53−30
@@ -24,36 +24,40 @@
24
24
25module Gen.Types
25module Gen.Types
26 ( module Gen.Types
26 ( module Gen.Types
27+ , module Gen.Types.Help
28+ , module Gen.Types.Id
27 , module Gen.Types.Map
29 , module Gen.Types.Map
28 , module Gen.Types.NS
30 , module Gen.Types.NS
29− , module Gen.Types.Id
30 ) where
31 ) where
31
32
32import Control.Applicative
33import Control.Applicative
33−import Control.Lens hiding ((.=))
34+import Control.Lens hiding ((.=))
34−import Data.Aeson hiding (Bool, String)
35+import Data.Aeson hiding (Bool, String)
35import Data.Aeson.TH
36import Data.Aeson.TH
36import Data.Char
37import Data.Char
37−import Data.Function (on)
38+import Data.Function (on)
38−import Data.List.NonEmpty (NonEmpty (..))
39+import Data.List.NonEmpty (NonEmpty (..))
39−import qualified Data.List.NonEmpty as NE
40+import qualified Data.List.NonEmpty as NE
40import Data.Maybe
41import Data.Maybe
41import Data.Ord
42import Data.Ord
42−import Data.Semigroup ((<>))
43+import Data.Semigroup ((<>))
43−import Data.Text (Text)
44+import Data.Text (Text)
44−import qualified Data.Text as Text
45+import qualified Data.Text as Text
45−import qualified Data.Text.Lazy as LText
46+import qualified Data.Text.Lazy as LText
46−import qualified Data.Text.Lazy.Builder as Build
47+import qualified Data.Text.Lazy.Builder as Build
47−import qualified Data.Text.Read as Read
48+import qualified Data.Text.Read as Read
48−import qualified Filesystem.Path.CurrentOS as Path
49+import qualified Filesystem.Path.CurrentOS as Path
49import Formatting
50import Formatting
50import Gen.Text
51import Gen.Text
52+import Gen.Types.Help
51import Gen.Types.Id
53import Gen.Types.Id
52import Gen.Types.Map
54import Gen.Types.Map
53import Gen.Types.NS
55import Gen.Types.NS
54import GHC.Generics
56import GHC.Generics
55import GHC.TypeLits
57import GHC.TypeLits
58+import Language.Haskell.Exts (Name)
59+import Language.Haskell.Exts.Pretty (Pretty, prettyPrint)
56−import Text.EDE (Template)
60+import Text.EDE (Template)
57
61
58default (Text)
62default (Text)
59
63
@@ -141,7 +145,7 @@ data Location
141deriveJSON (js "") ''Location
145deriveJSON (js "") ''Location
142
146
143data Info = Info
147data Info = Info
144− { _description :: Maybe Text
148+ { _description :: Maybe Help
145 , _defaulted :: Maybe Text
149 , _defaulted :: Maybe Text
146 , _required :: !Bool
150 , _required :: !Bool
147 , _location :: Maybe Location
151 , _location :: Maybe Location
@@ -164,8 +168,13 @@ parameter s = s ^. required && isNothing (s ^. defaulted)
164data Lit
168data Lit
165 = Text
169 = Text
166 | Bool
170 | Bool
167− | Int
171+ | Float
168− | Long
172+ | Double
173+ | Byte
174+ | UInt32
175+ | UInt64
176+ | Int32
177+ | Int64
169 | Nat
178 | Nat
170 | Time
179 | Time
171 deriving (Eq, Show)
180 deriving (Eq, Show)
@@ -178,8 +187,13 @@ instance FromJSON Lit where
178 "string" -> pure Text
187 "string" -> pure Text
179 "boolean" -> pure Bool
188 "boolean" -> pure Bool
180 -- Formats
189 -- Formats
190+ "float" -> pure Float
191+ "double" -> pure Double
192+ "byte" -> pure (nat n Byte)
193+ "uint32" -> pure (nat n UInt32)
181− "uint64" -> pure (nat n Long)
194+ "uint64" -> pure (nat n UInt64)
182− "int32" -> pure (nat n Int)
195+ "int32" -> pure (nat n Int32)
196+ "int64" -> pure (nat n Int64)
183 "date-time" -> pure Time
197 "date-time" -> pure Time
184 e -> fail $
198 e -> fail $
185 "Unable to parse Lit from " ++ Text.unpack e
199 "Unable to parse Lit from " ++ Text.unpack e
@@ -213,8 +227,8 @@ instance FromJSON (Fix Schema) where
213 Fix <$> (ref i o <|> schema i o)
227 Fix <$> (ref i o <|> schema i o)
214 where
228 where
215 schema i o = o .: "type" >>= \case
229 schema i o = o .: "type" >>= \case
216− "object" -> Obj i <$> o .: "properties"
230+ "object" -> Obj i <$> o .:? "properties" .!= mempty
217− "array" -> Arr i <$> o .: "items"
231+ "array" -> Arr i <$> o .: "items"
218 "any" -> pure (Any i)
232 "any" -> pure (Any i)
219 _ -> enm i o <|> Lit i <$> parseJSON (Object o)
233 _ -> enm i o <|> Lit i <$> parseJSON (Object o)
220
234
@@ -250,30 +264,39 @@ instance FromJSON Param where
250
264
251deriveToJSON (js "") ''Param
265deriveToJSON (js "") ''Param
252
266
267+data Syn a = Syn { syntax :: a }
268+
269+instance Pretty a => ToJSON (Syn a) where
270+ toJSON = toJSON . prettyPrint . syntax
271+
253−data Fun = Fun' Text Rendered Rendered
272+data Fun = Fun' Name (Maybe Help) Rendered Rendered
254
273
255instance ToJSON Fun where
274instance ToJSON Fun where
256− toJSON (Fun' h s d) = object
275+ toJSON (Fun' n h s d) = object
276+ [ "name" .= Syn n
257− [ "help" .= h
277+ , "help" .= h
258 , "sig" .= s
278 , "sig" .= s
259 , "decl" .= d
279 , "decl" .= d
260 ]
280 ]
261
281
262data Data
282data Data
263− = Sum Text Rendered
283+ = Sum Name (Maybe Help) Rendered
264− | Prod Rendered Fun [Fun]
284+ | Prod Name (Maybe Help) Rendered Fun [Fun]
265
285
266instance ToJSON Data where
286instance ToJSON Data where
267 toJSON = \case
287 toJSON = \case
268− Sum h d -> object
288+ Sum n h d -> object
289+ [ "name" .= Syn n
269− [ "type" .= "sum"
290+ , "type" .= "sum"
270 , "decl" .= d
291 , "decl" .= d
271 , "help" .= h
292 , "help" .= h
272 ]
293 ]
273
294
274− Prod d c ls -> object
295+ Prod n h d c ls -> object
296+ [ "name" .= Syn n
275− [ "type" .= "prod"
297+ , "type" .= "prod"
276 , "decl" .= d
298 , "decl" .= d
299+ , "help" .= h
277 , "ctor" .= c
300 , "ctor" .= c
278 , "lenses" .= ls
301 , "lenses" .= ls
279 ]
302 ]
gen/src/Gen/Types/Help.hsnew file+86
@@ -0,0 +1,86 @@
1+{-# LANGUAGE LambdaCase #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+
4+-- Module : Gen.Types.Help
5+-- Copyright : (c) 2015 Brendan Hay
6+-- License : Mozilla Public License, v. 2.0.
7+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
8+-- Stability : provisional
9+-- Portability : non-portable (GHC extensions)
10+
11+module Gen.Types.Help
12+ ( Help
13+ , Desc (..)
14+ , rawHelpText
15+ ) where
16+
17+import Data.Aeson
18+import Data.Char (isSpace)
19+import Data.String
20+import Data.Text (Text)
21+import qualified Data.Text as Text
22+import Text.Pandoc
23+import Text.Pandoc.Pretty
24+
25+data Help
26+ = Help [Help]
27+ | Pan Pandoc
28+ | Raw Text
29+ deriving (Eq)
30+
31+instance Monoid Help where
32+ mempty = Help []
33+ mappend x y =
34+ case (x, y) of
35+ (Help a, Help b) -> Help (a <> b)
36+ (Pan a, Pan b) -> Pan (a <> b)
37+ (Raw a, Raw b) -> Raw (a <> b)
38+ (Help a, b) -> Help (a <> [b])
39+ (a, Help b) -> Help (a : b)
40+ (a, b) -> Help [a, b]
41+
42+-- | Empty Show instance to avoid verbose debugging output.
43+instance Show Help where
44+ show = const mempty
45+
46+instance IsString Help where
47+ fromString = rawHelpText . fromString
48+
49+rawHelpText :: Text -> Help
50+rawHelpText = Raw
51+
52+instance FromJSON Help where
53+ parseJSON = withText "help" $
54+ either (fail . show) pure
55+ . fmap Pan
56+ . readHtml def
57+ . Text.unpack
58+
59+instance ToJSON Help where
60+ toJSON = toJSON
61+ . mappend "-- |"
62+ . Text.map f
63+ . Text.drop 2
64+ . wrap "-- "
65+ . flatten
66+ where
67+ f '@' = '\''
68+ f x = x
69+
70+data Desc = Desc !Int Help
71+
72+instance ToJSON Desc where
73+ toJSON (Desc n h) = toJSON . wrap (replicate n ' ') $ flatten h
74+
75+flatten :: Help -> String
76+flatten = \case
77+ Help xs -> foldMap flatten xs
78+ Pan d -> writeHaddock def d
79+ Raw t -> Text.unpack t
80+
81+wrap :: String -> String -> Text
82+wrap sep =
83+ Text.dropWhileEnd isSpace
84+ . render (Just 76)
85+ . prefixed sep
86+ . fromString
gen/template/_include/type.ede+18−2
@@ -1,18 +1,34 @@
1+{% if type.help %}
2+{{ type.help }}
3+{% endif %}
1{% case type.type %}
4{% case type.type %}
2{% when "prod" %}
5{% when "prod" %}
6+--
7+-- /See:/ '{{ type.ctor.name }}' smart constructor.
3{{ type.decl }}
8{{ type.decl }}
4
9
10+ {% if type.ctor.help %}
5{{ type.ctor.help }}
11{{ type.ctor.help }}
12+ {% endif %}
13+--
14+ {% for lens in type.lenses %}
15+ {% if lens.first %}
16+-- Use one of the following lenses to modify other fields as desired:
17+ {% endif %}
18+--
19+-- * '{{ lens.value.name }}'
20+ {% endfor %}
6{{ type.ctor.sig }}
21{{ type.ctor.sig }}
7{{ type.ctor.decl }}
22{{ type.ctor.decl }}
8 {% for lens in type.lenses %}
23 {% for lens in type.lenses %}
9
24
25+ {% if lens.value.help %}
10{{ lens.value.help }}
26{{ lens.value.help }}
27+ {% endif %}
11{{ lens.value.sig }}
28{{ lens.value.sig }}
12{{ lens.value.decl }}
29{{ lens.value.decl }}
13− {% endfor %}
30+ {% endfor %}
14 {% when "sum" %}
31 {% when "sum" %}
15−{{ type.help }}
16{{ type.decl }}
32{{ type.decl }}
17{% else %}
33{% else %}
18 Error: Unrecognised type '{{ type.type }}'
34 Error: Unrecognised type '{{ type.type }}'
gen/template/toc.ede+27
@@ -5,6 +5,29 @@
5-- /See:/ <{{ documentationLink }} {{ title }} Reference>
5-- /See:/ <{{ documentationLink }} {{ title }} Reference>
6module {{ moduleName }}
6module {{ moduleName }}
7 (
7 (
8+ -- * API Definition
9+ {{ name }}
10+
11+ -- * Resources
12+ -- $resources
13+
14+ -- * Types
15+ {% for schema in schemas %}
16+ {% case schema.value.type %}
17+ {% when "prod" %}
18+
19+ -- ** {{ schema.value.name }}
20+ , {{ schema.value.name }}
21+ , {{ schema.value.ctor.name }}
22+ {% for lens in schema.value.lenses %}
23+ , {{ lens.value.name }}
24+ {% endfor %}
25+ {% when "sum" %}
26+
27+ -- ** {{ schema.value.name }}
28+ , {{ schema.value.name }} (..)
29+ {% endcase %}
30+ {% endfor %}
8 ) where
31 ) where
9
32
10{% for module in exposedModules %}
33{% for module in exposedModules %}
@@ -12,3 +35,7 @@ module {{ moduleName }}
12import {{ module.value }}
35import {{ module.value }}
13 {% endif %}
36 {% endif %}
14{% endfor %}
37{% endfor %}
38+
39+{- $resources
40+TODO
41+-}
gen/template/types.ede+21−1
@@ -2,13 +2,33 @@
2--
2--
3module {{ moduleName }}
3module {{ moduleName }}
4 (
4 (
5+ -- * API Definition
6+ {{ name }}
7+ {% for schema in schemas %}
8+ {% case schema.value.type %}
9+ {% when "prod" %}
10+
11+ -- * {{ schema.value.name }}
12+ , {{ schema.value.name }}
13+ , {{ schema.value.ctor.name }}
14+ {% for lens in schema.value.lenses %}
15+ , {{ lens.value.name }}
16+ {% endfor %}
17+ {% when "sum" %}
18+
19+ -- * {{ schema.value.name }}
20+ , {{ schema.value.name }} (..)
21+ {% endcase %}
22+ {% endfor %}
5 ) where
23 ) where
6
24
7{% for import in moduleImports %}
25{% for import in moduleImports %}
8import {{ import.value }}
26import {{ import.value }}
9{% endfor %}
27{% endfor %}
10
28
29+{{ name }} :: a
30+{{ name }} = error "{{ name }}"
11{% for schema in schemas %}
31{% for schema in schemas %}
12− {% include "_include/type.ede" with type = schema.value %}
13
32
33+ {% include "_include/type.ede" with type = schema.value %}
14{% endfor %}
34{% endfor %}