@@ -2,10 +2,8 @@ module Main (main) where
22
33import Control.Monad.Writer.Strict
44import Data.Aeson hiding (Options)
5−import Data.Aeson.Types (Parser)
65import Data.HashMap.Strict qualified as HM
76import Data.Map.Lazy qualified as M
8−import Data.Text qualified as T
97import Data.Vector (Vector)
108import Data.Vector qualified as V
119import Data.Yaml as Yaml
@@ -70,10 +68,25 @@ elm datattypes =
7068 in makeElmModuleFromETypeDef "Bridge" types
7169
7270elmType :: Text -> Datatype -> Writer [ETypeDef] EType
73−elmType name BoolType = pure $ ETyCon $ ETCon "Bool"
74−elmType name IntType = pure $ ETyCon $ ETCon "Int"
75−elmType name FloatType = pure $ ETyCon $ ETCon "Float"
76−elmType name StringType = pure $ ETyCon $ ETCon "String"
71+elmType _ BoolType = pure $ ETyCon $ ETCon "Bool"
72+elmType _ IntType = pure $ ETyCon $ ETCon "Int"
73+elmType _ FloatType = pure $ ETyCon $ ETCon "Float"
74+elmType _ StringType = pure $ ETyCon $ ETCon "String"
75+elmType name (List inner) = do
76+ -- fields' <- traverse (\(k, v) -> (toString k,) <$> elmType (name <> "_" <> k) v) $ M.toList fields
77+ inner' <- elmType name inner
78+ tell
79+ [ ETypePrimAlias
80+ EPrimAlias
81+ { epa_name =
82+ ETypeName
83+ { et_name = toString name <> "_List",
84+ et_args = []
85+ },
86+ epa_type = ETyApp (ETyCon (ETCon "List")) inner'
87+ }
88+ ]
89+ pure $ ETyCon $ ETCon $ toString name
7790elmType name (ProductType fields) = do
7891 fields' <- traverse (\(k, v) -> (toString k,) <$> elmType (name <> "_" <> k) v) $ M.toList fields
7992 tell
@@ -125,6 +138,34 @@ psType _ BoolType = pure psBool
125138psType _ IntType = pure psInt
126139psType _ FloatType = pure psNumber
127140psType _ StringType = pure psString
141+psType name (List inner) = do
142+ inner' <- psType name inner
143+ let ti =
144+ TypeInfo
145+ { _typePackage = "bridge",
146+ _typeModule = "Bridge",
147+ _typeName = name <> "_List",
148+ _typeParameters = []
149+ }
150+ tell
151+ [ PS.SumType
152+ ti
153+ [ DataConstructor
154+ { _sigConstructor = name <> "_List",
155+ _sigValues =
156+ Left
157+ [ TypeInfo
158+ { _typePackage = "builtins",
159+ _typeModule = "Prim",
160+ _typeName = "Array",
161+ _typeParameters = [inner']
162+ }
163+ ]
164+ }
165+ ]
166+ allInstances
167+ ]
168+ pure ti
128169psType name (SumDatatype (SumType sums)) = do
129170 sums' <- traverse (\(k, v) -> (k,) <$> traverse (psType (name <> "_" <> k)) v) $ M.toList sums
130171 let ti =