-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCodegenNewtype.purs
42 lines (38 loc) · 1.21 KB
/
CodegenNewtype.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module CodegenNewtype where
import Prelude
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Effect (Effect)
import Partial.Unsafe (unsafePartial)
import PureScript.CST.Types (Module)
import Test.Util (log)
import Tidy.Codegen (declNewtype, declNewtypeSignature, module_, printModule, typeApp, typeArrow, typeCtor, typeForall, typeRecord, typeVar)
test :: Module Void
test = unsafePartial do
module_ "Test.Newtype" [] []
[ declNewtypeSignature "Const" do
typeForall [ typeVar "k" ]
( typeArrow
[ typeCtor "Type"
, typeVar "k"
]
(typeCtor "Type")
)
, declNewtype "Const" [ typeVar "a", typeVar "b" ]
"Const"
(typeVar "a")
, declNewtype "User" []
"User"
( typeRecord
[ Tuple "id" (typeCtor "UserId")
, Tuple "name" (typeCtor "String")
, Tuple "age" (typeCtor "Int")
, Tuple "email" (typeCtor "Email")
, Tuple "phone" (typeCtor "PhoneNumber")
, Tuple "followers" (typeApp (typeCtor "Array") [ typeCtor "UserId" ])
]
Nothing
)
]
main :: Effect Unit
main = log $ printModule test