1-----------------------------------------------------------------------------
3-- Module : Language.PureScript.Types
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15{-# LANGUAGE DeriveDataTypeable #-}
17module Language.PureScript.Types where
20import Language.PureScript.Names
21import Language.PureScript.Unknown (Unknown(..))
24 = TUnknown (Unknown Type)
30 | Function [PolyType] Type
32 | TypeConstructor (Qualified ProperName)
34 | SaturatedTypeSynonym (Qualified ProperName) [Type]
36 | Skolem Int deriving (Show, Eq, Data, Typeable)
41 = RUnknown (Unknown Row)
44 | RCons String Type Row
45 | RSkolem Int deriving (Show, Eq, Data, Typeable)
47typesToRow :: [(String, Type)] -> Row
49typesToRow ((name, ty):tys) = RCons name ty (typesToRow tys)
51rowToList :: Row -> ([(String, Type)], Row)
52rowToList (RCons name ty row) = let (tys, rest) = rowToList row
53 in ((name, ty):tys, rest)
56rowFromList :: ([(String, Type)], Row) -> Row
57rowFromList ([], r) = r
58rowFromList ((name, t):ts, r) = RCons name t (rowFromList (ts, r))
60isMonoType :: Type -> Bool
61isMonoType (ForAll _ _) = False
62isMonoType ty = isPolyType ty
64isPolyType :: Type -> Bool
65isPolyType (Array ty) = isMonoType ty
66isPolyType (Object ps) = all isMonoType (map snd . fst $ rowToList ps)
67isPolyType (Function args ret) = all isPolyType args && isMonoType ret
68isPolyType (TypeApp t1 t2) = isMonoType t1 && isMonoType t2
69isPolyType (SaturatedTypeSynonym _ args) = all isMonoType args
70isPolyType (ForAll idents ty) = isPolyType ty
73mkForAll :: [String] -> Type -> Type
74mkForAll = flip . foldl . flip $ ForAll
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list