git.iko.soy/rowtype-yoga/purescript-native
on 60560bd help sign in
81 lines 2.0 kB history raw
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-----------------------------------------------------------------------------
15module Language.PureScript.Prim where
17import Language.PureScript.Kinds
18import Language.PureScript.Names
19import Language.PureScript.Types
21import qualified Language.PureScript.Constants as C
23import qualified Data.Map as M
25-- |
26-- Construct a ProperName in the Prim module
27--
28primName :: String -> Qualified ProperName
29primName = Qualified (Just $ ModuleName [ProperName C.prim]) . ProperName
31-- |
32-- Construct a type in the Prim module
33--
34primTy :: String -> Type
35primTy = TypeConstructor . primName
37-- |
38-- Type constructor for functions
39--
40tyFunction :: Type
41tyFunction = primTy "Function"
43-- |
44-- Type constructor for strings
45--
46tyString :: Type
47tyString = primTy "String"
49-- |
50-- Type constructor for numbers
51--
52tyNumber :: Type
53tyNumber = primTy "Number"
55-- |
56-- Type constructor for booleans
57--
58tyBoolean :: Type
59tyBoolean = primTy "Boolean"
61-- |
62-- Type constructor for arrays
63--
64tyArray :: Type
65tyArray = primTy "Array"
67-- |
68-- Smart constructor for function types
69--
70function :: Type -> Type -> Type
71function t1 = TypeApp (TypeApp tyFunction t1)
73-- |
74-- The primitive types in the external javascript environment with their associated kinds.
75--
76primTypes :: M.Map (Qualified ProperName) Kind
77primTypes = M.fromList [ (primName "Function" , FunKind Star (FunKind Star Star))
78 , (primName "Array" , FunKind Star Star)
79 , (primName "String" , Star)
80 , (primName "Number" , Star)
81 , (primName "Boolean" , Star) ]