on master help sign in
Add a bunch of type primitives
commite28d01ea01f9f5c59143cb937116928c50bfc888 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 8 Nov 2017, 17:28 (9 years ago) parent4a6c4a0
3 files changed+106−12
src/AST/Module/Name.hs+55−2 src/Elm/Name.hs+4 src/Type/Type.hs+47−10
src/AST/Module/Name.hs+55−2
@@ -2,9 +2,11 @@
22{-# LANGUAGE OverloadedStrings #-}
33module AST.Module.Name
44 ( Canonical(..)
5− , basics, maybe, list, array
5+ , basics, char, string
6+ , maybe, list, array
67 , platform, cmd, sub
78 , jsonDecode, jsonEncode
9+ , webgl, vector2, vector3, vector4, matrix4
810 , canonicalToText
911 , isKernel, getKernel, canonicalIsKernel
1012 )
@@ -34,7 +36,7 @@ data Canonical =
3436
3537
3638
37−-- HELPERS
39+-- PRIMITIVES
3840
3941
4042{-# NOINLINE basics #-}
@@ -42,6 +44,20 @@ basics :: Canonical
4244basics = Canonical Pkg.core "Basics"
4345
4446
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+
4561{-# NOINLINE maybe #-}
4662maybe :: Canonical
4763maybe = Canonical Pkg.core "Maybe"
@@ -57,6 +73,10 @@ array :: Canonical
5773array = Canonical Pkg.core "Array"
5874
5975
76+
77+-- EFFECTS
78+
79+
6080{-# NOINLINE platform #-}
6181platform :: Canonical
6282platform = Canonical Pkg.core "Platform"
@@ -72,6 +92,10 @@ sub :: Canonical
7292sub = Canonical Pkg.core "Platform.Sub"
7393
7494
95+
96+-- JSON
97+
98+
7599{-# NOINLINE jsonDecode #-}
76100jsonDecode :: Canonical
77101jsonDecode = Canonical Pkg.core "Json.Decode"
@@ -83,6 +107,35 @@ jsonEncode = Canonical Pkg.core "Json.Encode"
83107
84108
85109
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+
86139-- CONVERSIONS
87140
88141
src/Elm/Name.hs+4
@@ -6,6 +6,7 @@ module Elm.Name
66 , int, float, bool, char, string
77 , maybe, list, array
88 , task, router, cmd, sub
9+ , shader
910 )
1011 where
1112
@@ -86,3 +87,6 @@ sub :: Name
8687sub = "Sub"
8788
8889
90+{-# NOINLINE shader #-}
91+shader :: Name
92+shader = "Shader"
src/Type/Type.hs+47−10
@@ -11,7 +11,9 @@ module Type.Type
1111 , Mark
1212 , noMark
1313 , nextMark
14− , (==>), float, char, string, bool
14+ , (==>)
15+ , int, float, char, string, bool
16+ , vec2, vec3, vec4, mat4, texture
1517 , mkFlexVar
1618 , mkFlexNumber
1719 , unnamedFlexVar
@@ -22,6 +24,7 @@ module Type.Type
2224 )
2325 where
2426
27+
2528import Control.Monad.State.Strict (StateT, liftIO)
2629import qualified Control.Monad.State.Strict as State
2730import qualified Data.Char as Char
@@ -139,7 +142,7 @@ nextMark (Mark mark) =
139142
140143
141144
142−-- TYPE HELPERS
145+-- FUNCTION TYPES
143146
144147
145148infixr 9 ==>
@@ -151,28 +154,62 @@ infixr 9 ==>
151154 FunN
152155
153156
157+
158+-- PRIMITIVE TYPES
159+
160+
161+{-# NOINLINE int #-}
162+int :: Type
163+int = AppN ModuleName.basics "Int" []
164+
165+
154166{-# NOINLINE float #-}
155167float :: Type
156−float =
157− AppN ModuleName.basics "Float" []
168+float = AppN ModuleName.basics "Float" []
158169
159170
160171{-# NOINLINE char #-}
161172char :: Type
162−char =
163− AppN ModuleName.basics "Char" []
173+char = AppN ModuleName.char "Char" []
164174
165175
166176{-# NOINLINE string #-}
167177string :: Type
168−string =
169− AppN ModuleName.basics "String" []
178+string = AppN ModuleName.string "String" []
170179
171180
172181{-# NOINLINE bool #-}
173182bool :: 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" []
176213
177214
178215