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)
47rowToList :: Row -> ([(String, Type)], Row)
48rowToList (RCons name ty row) = let (tys, rest) = rowToList row
49 in ((name, ty):tys, rest)
52rowFromList :: ([(String, Type)], Row) -> Row
53rowFromList ([], r) = r
54rowFromList ((name, t):ts, r) = RCons name t (rowFromList (ts, r))
56isMonoType :: Type -> Bool
57isMonoType (ForAll _ _) = False
58isMonoType ty = isPolyType ty
60isPolyType :: Type -> Bool
61isPolyType (Array ty) = isMonoType ty
62isPolyType (Object ps) = all isPolyType (map snd . fst $ rowToList ps)
63isPolyType (Function args ret) = all isPolyType args && isPolyType ret
64isPolyType (TypeApp t1 t2) = isMonoType t1 && isMonoType t2
65isPolyType (SaturatedTypeSynonym _ args) = all isPolyType args
66isPolyType (ForAll _ ty) = isPolyType ty
69mkForAll :: [String] -> Type -> Type
70mkForAll = 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