on master help sign in
Add a bunch of type primitives
e28d01eEvan Czaplicki
src/AST/Module/Name.hs+55−2
@@ -2,9 +2,11 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3module AST.Module.Name
3module AST.Module.Name
4 ( Canonical(..)
4 ( Canonical(..)
5+ , basics, char, string
5− , basics, maybe, list, array
6+ , maybe, list, array
6 , platform, cmd, sub
7 , platform, cmd, sub
7 , jsonDecode, jsonEncode
8 , jsonDecode, jsonEncode
9+ , webgl, vector2, vector3, vector4, matrix4
8 , canonicalToText
10 , canonicalToText
9 , isKernel, getKernel, canonicalIsKernel
11 , isKernel, getKernel, canonicalIsKernel
10 )
12 )
@@ -34,7 +36,7 @@ data Canonical =
34
36
35
37
36
38
37−-- HELPERS
39+-- PRIMITIVES
38
40
39
41
40{-# NOINLINE basics #-}
42{-# NOINLINE basics #-}
@@ -42,6 +44,20 @@ basics :: Canonical
42basics = Canonical Pkg.core "Basics"
44basics = Canonical Pkg.core "Basics"
43
45
44
46
47+{-# NOINLINE char #-}
48+char :: Canonical
49+char = Canonical Pkg.core "Char"
50+
51+
52+{-# NOINLINE string #-}
53+string :: Canonical
54+string = Canonical Pkg.core "String"
55+
56+
57+
58+-- CONTAINERS
59+
60+
45{-# NOINLINE maybe #-}
61{-# NOINLINE maybe #-}
46maybe :: Canonical
62maybe :: Canonical
47maybe = Canonical Pkg.core "Maybe"
63maybe = Canonical Pkg.core "Maybe"
@@ -57,6 +73,10 @@ array :: Canonical
57array = Canonical Pkg.core "Array"
73array = Canonical Pkg.core "Array"
58
74
59
75
76+
77+-- EFFECTS
78+
79+
60{-# NOINLINE platform #-}
80{-# NOINLINE platform #-}
61platform :: Canonical
81platform :: Canonical
62platform = Canonical Pkg.core "Platform"
82platform = Canonical Pkg.core "Platform"
@@ -72,6 +92,10 @@ sub :: Canonical
72sub = Canonical Pkg.core "Platform.Sub"
92sub = Canonical Pkg.core "Platform.Sub"
73
93
74
94
95+
96+-- JSON
97+
98+
75{-# NOINLINE jsonDecode #-}
99{-# NOINLINE jsonDecode #-}
76jsonDecode :: Canonical
100jsonDecode :: Canonical
77jsonDecode = Canonical Pkg.core "Json.Decode"
101jsonDecode = Canonical Pkg.core "Json.Decode"
@@ -83,6 +107,35 @@ jsonEncode = Canonical Pkg.core "Json.Encode"
83
107
84
108
85
109
110+-- WEBGL
111+
112+
113+{-# NOINLINE webgl #-}
114+webgl :: Canonical
115+webgl = Canonical Pkg.webgl "WebGL"
116+
117+
118+{-# NOINLINE vector2 #-}
119+vector2 :: Canonical
120+vector2 = Canonical Pkg.linearAlgebra "Math.Vector2"
121+
122+
123+{-# NOINLINE vector3 #-}
124+vector3 :: Canonical
125+vector3 = Canonical Pkg.linearAlgebra "Math.Vector3"
126+
127+
128+{-# NOINLINE vector4 #-}
129+vector4 :: Canonical
130+vector4 = Canonical Pkg.linearAlgebra "Math.Vector4"
131+
132+
133+{-# NOINLINE matrix4 #-}
134+matrix4 :: Canonical
135+matrix4 = Canonical Pkg.linearAlgebra "Math.Matrix4"
136+
137+
138+
86-- CONVERSIONS
139-- CONVERSIONS
87
140
88
141
src/Elm/Name.hs+4
@@ -6,6 +6,7 @@ module Elm.Name
6 , int, float, bool, char, string
6 , int, float, bool, char, string
7 , maybe, list, array
7 , maybe, list, array
8 , task, router, cmd, sub
8 , task, router, cmd, sub
9+ , shader
9 )
10 )
10 where
11 where
11
12
@@ -86,3 +87,6 @@ sub :: Name
86sub = "Sub"
87sub = "Sub"
87
88
88
89
90+{-# NOINLINE shader #-}
91+shader :: Name
92+shader = "Shader"
src/Type/Type.hs+47−10
@@ -11,7 +11,9 @@ module Type.Type
11 , Mark
11 , Mark
12 , noMark
12 , noMark
13 , nextMark
13 , nextMark
14+ , (==>)
14− , (==>), float, char, string, bool
15+ , int, float, char, string, bool
16+ , vec2, vec3, vec4, mat4, texture
15 , mkFlexVar
17 , mkFlexVar
16 , mkFlexNumber
18 , mkFlexNumber
17 , unnamedFlexVar
19 , unnamedFlexVar
@@ -22,6 +24,7 @@ module Type.Type
22 )
24 )
23 where
25 where
24
26
27+
25import Control.Monad.State.Strict (StateT, liftIO)
28import Control.Monad.State.Strict (StateT, liftIO)
26import qualified Control.Monad.State.Strict as State
29import qualified Control.Monad.State.Strict as State
27import qualified Data.Char as Char
30import qualified Data.Char as Char
@@ -139,7 +142,7 @@ nextMark (Mark mark) =
139
142
140
143
141
144
142−-- TYPE HELPERS
145+-- FUNCTION TYPES
143
146
144
147
145infixr 9 ==>
148infixr 9 ==>
@@ -151,28 +154,62 @@ infixr 9 ==>
151 FunN
154 FunN
152
155
153
156
157+
158+-- PRIMITIVE TYPES
159+
160+
161+{-# NOINLINE int #-}
162+int :: Type
163+int = AppN ModuleName.basics "Int" []
164+
165+
154{-# NOINLINE float #-}
166{-# NOINLINE float #-}
155float :: Type
167float :: Type
156−float =
157− AppN ModuleName.basics "Float" []
168+float = AppN ModuleName.basics "Float" []
158
169
159
170
160{-# NOINLINE char #-}
171{-# NOINLINE char #-}
161char :: Type
172char :: Type
162−char =
163− AppN ModuleName.basics "Char" []
173+char = AppN ModuleName.char "Char" []
164
174
165
175
166{-# NOINLINE string #-}
176{-# NOINLINE string #-}
167string :: Type
177string :: Type
168−string =
169− AppN ModuleName.basics "String" []
178+string = AppN ModuleName.string "String" []
170
179
171
180
172{-# NOINLINE bool #-}
181{-# NOINLINE bool #-}
173bool :: Type
182bool :: Type
174−bool =
175− AppN ModuleName.basics "Bool" []
183+bool = AppN ModuleName.basics "Bool" []
184+
185+
186+
187+-- WEBGL TYPES
188+
189+
190+{-# NOINLINE vec2 #-}
191+vec2 :: Type
192+vec2 = AppN ModuleName.vector2 "Vec2" []
193+
194+
195+{-# NOINLINE vec3 #-}
196+vec3 :: Type
197+vec3 = AppN ModuleName.vector3 "Vec3" []
198+
199+
200+{-# NOINLINE vec4 #-}
201+vec4 :: Type
202+vec4 = AppN ModuleName.vector4 "Vec4" []
203+
204+
205+{-# NOINLINE mat4 #-}
206+mat4 :: Type
207+mat4 = AppN ModuleName.matrix4 "Mat4" []
208+
209+
210+{-# NOINLINE texture #-}
211+texture :: Type
212+texture = AppN ModuleName.webgl "Texture" []
176
213
177
214
178
215