@@ -0,0 +1,69 @@
1+-----------------------------------------------------------------------------
2+--
3+-- Module : Language.PureScript.Prim
4+-- Copyright : (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors
5+-- License : MIT
6+--
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
9+-- Portability :
10+--
11+-- |
12+--
13+-----------------------------------------------------------------------------
14+
15+module Language.PureScript.Prim where
16+
17+import Language.PureScript.Kinds
18+import Language.PureScript.Names
19+import Language.PureScript.Types
20+
21+import qualified Data.Map as M
22+
23+-- |
24+-- Type constructor for functions
25+--
26+tyFunction :: Type
27+tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Function")
28+
29+-- |
30+-- Type constructor for strings
31+--
32+tyString :: Type
33+tyString = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "String")
34+
35+-- |
36+-- Type constructor for numbers
37+--
38+tyNumber :: Type
39+tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Number")
40+
41+-- |
42+-- Type constructor for booleans
43+--
44+tyBoolean :: Type
45+tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Boolean")
46+
47+-- |
48+-- Type constructor for arrays
49+--
50+tyArray :: Type
51+tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Array")
52+
53+-- |
54+-- Smart constructor for function types
55+--
56+function :: Type -> Type -> Type
57+function t1 = TypeApp (TypeApp tyFunction t1)
58+
59+-- |
60+-- The primitive types in the external javascript environment with their associated kinds.
61+--
62+primTypes :: M.Map (Qualified ProperName) Kind
63+primTypes = M.fromList [ (primName "Function" , FunKind Star (FunKind Star Star))
64+ , (primName "Array" , FunKind Star Star)
65+ , (primName "String" , Star)
66+ , (primName "Number" , Star)
67+ , (primName "Boolean" , Star) ]
68+ where
69+ primName name = Qualified (Just $ ModuleName [ProperName "Prim"]) (ProperName name)