@@ -0,0 +1,69 @@
1+-----------------------------------------------------------------------------
3+-- Module : Language.PureScript.Prim
4+-- Copyright : (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
13+-----------------------------------------------------------------------------
15+module Language.PureScript.Prim where
17+import Language.PureScript.Kinds
18+import Language.PureScript.Names
19+import Language.PureScript.Types
21+import qualified Data.Map as M
24+-- Type constructor for functions
27+tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Function")
30+-- Type constructor for strings
33+tyString = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "String")
36+-- Type constructor for numbers
39+tyNumber = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Number")
42+-- Type constructor for booleans
45+tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Boolean")
48+-- Type constructor for arrays
51+tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName [ProperName "Prim"]) (ProperName "Array")
54+-- Smart constructor for function types
56+function :: Type -> Type -> Type
57+function t1 = TypeApp (TypeApp tyFunction t1)
60+-- The primitive types in the external javascript environment with their associated kinds.
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) ]
69+ primName name = Qualified (Just $ ModuleName [ProperName "Prim"]) (ProperName name)