1-----------------------------------------------------------------------------
3-- Module : PureScript.TypeChecker.Monad
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-}
17module PureScript.TypeChecker.Monad where
19import PureScript.Types
20import PureScript.Kinds
22import Control.Applicative
23import Control.Monad.State
24import Control.Monad.Error
26import qualified Data.Map as M
28data Environment = Environment
29 { names :: M.Map String Type
30 , types :: M.Map String Kind
33emptyEnvironment :: Environment
34emptyEnvironment = Environment M.empty M.empty
36newtype Check a = Check { unCheck :: StateT Environment (Either String) a } deriving (Functor, Monad, Applicative, MonadPlus, MonadState Environment, MonadError String)
38check :: Check a -> Either String a
39check = flip evalStateT emptyEnvironment . unCheck
41guardWith :: (MonadError e m) => e -> Bool -> m ()
42guardWith _ True = return ()
43guardWith e False = throwError e
45rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
46rethrow f = flip catchError $ \e -> throwError (f e)
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