git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge remote-tracking branch 'hdgarrood/update-deps'
commitfe55e94459f22d3779fd6bdbaf7e9f4fbe3a5784 authorPhil Freeman <paf31@cantab.net> dateFri 20 Feb 2015, 17:26 (12 years ago) parent0d6711cbcea1c0
24 files changed+217−52
psc-make/Main.hs+4−4 psc/Main.hs+1−1 psci/Main.hs+4−4 purescript.cabal+9−8 src/Control/Monad/Unify.hs+155 src/Language/PureScript.hs+1−1 src/Language/PureScript/Errors.hs+10−4 src/Language/PureScript/ModuleDependencies.hs+1−1 src/Language/PureScript/Sugar/CaseDeclarations.hs+1−1 src/Language/PureScript/Sugar/Names.hs+1−1 src/Language/PureScript/Sugar/Operators.hs+1−1 src/Language/PureScript/Sugar/TypeClasses.hs+1−1 src/Language/PureScript/Sugar/TypeDeclarations.hs+1−1 src/Language/PureScript/Supply.hs+1−1 src/Language/PureScript/TypeChecker.hs+1−1 src/Language/PureScript/TypeChecker/Entailment.hs+2−1 src/Language/PureScript/TypeChecker/Kinds.hs+1−1 src/Language/PureScript/TypeChecker/Monad.hs+7−7 src/Language/PureScript/TypeChecker/Rows.hs+1−1 src/Language/PureScript/TypeChecker/Skolems.hs+1−1 src/Language/PureScript/TypeChecker/Subsumption.hs+1−1 src/Language/PureScript/TypeChecker/Synonyms.hs+6−5 src/Language/PureScript/TypeChecker/Types.hs+5−4 src/Language/PureScript/TypeChecker/Unify.hs+1−1
psc-make/Main.hs+4−4
@@ -17,7 +17,7 @@
1717module Main where
1818
1919import Control.Applicative
20−import Control.Monad.Error
20+import Control.Monad.Except
2121import Control.Monad.Reader
2222
2323import Data.Version (showVersion)
@@ -52,14 +52,14 @@ readInput InputOptions{..} = do
5252 content <- forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readFile inFile
5353 return (if ioNoPrelude then content else (Left P.RebuildNever, P.prelude) : content)
5454
55−newtype Make a = Make { unMake :: ReaderT (P.Options P.Make) (ErrorT String IO) a }
55+newtype Make a = Make { unMake :: ReaderT (P.Options P.Make) (ExceptT String IO) a }
5656 deriving (Functor, Applicative, Monad, MonadIO, MonadError String, MonadReader (P.Options P.Make))
5757
5858runMake :: P.Options P.Make -> Make a -> IO (Either String a)
59−runMake opts = runErrorT . flip runReaderT opts . unMake
59+runMake opts = runExceptT . flip runReaderT opts . unMake
6060
6161makeIO :: IO a -> Make a
62−makeIO = Make . lift . ErrorT . fmap (either (Left . show) Right) . tryIOError
62+makeIO = Make . lift . ExceptT . fmap (either (Left . show) Right) . tryIOError
6363
6464instance P.MonadMake Make where
6565 getTimestamp path = makeIO $ do
psc/Main.hs+1−1
@@ -17,7 +17,7 @@
1717module Main where
1818
1919import Control.Applicative
20−import Control.Monad.Error
20+import Control.Monad.Except
2121import Control.Monad.Reader
2222
2323import Data.Maybe (fromMaybe)
psci/Main.hs+4−4
@@ -31,7 +31,7 @@ import qualified Data.Map as M
3131
3232import Control.Applicative
3333import Control.Monad
34−import Control.Monad.Error (ErrorT(..), MonadError)
34+import Control.Monad.Except (ExceptT(..), MonadError, runExceptT)
3535import Control.Monad.Reader (MonadReader, ReaderT, runReaderT)
3636import Control.Monad.Trans.Class
3737import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
@@ -325,14 +325,14 @@ newtype PSCI a = PSCI { runPSCI :: InputT (StateT PSCiState IO) a } deriving (Fu
325325psciIO :: IO a -> PSCI a
326326psciIO io = PSCI . lift $ lift io
327327
328−newtype Make a = Make { unMake :: ReaderT (P.Options P.Make) (ErrorT String IO) a }
328+newtype Make a = Make { unMake :: ReaderT (P.Options P.Make) (ExceptT String IO) a }
329329 deriving (Functor, Applicative, Monad, MonadError String, MonadReader (P.Options P.Make))
330330
331331runMake :: Make a -> IO (Either String a)
332−runMake = runErrorT . flip runReaderT options . unMake
332+runMake = runExceptT . flip runReaderT options . unMake
333333
334334makeIO :: IO a -> Make a
335−makeIO = Make . lift . ErrorT . fmap (either (Left . show) Right) . tryIOError
335+makeIO = Make . lift . ExceptT . fmap (either (Left . show) Right) . tryIOError
336336
337337instance P.MonadMake Make where
338338 getTimestamp path = makeIO $ do
purescript.cabal+9−8
@@ -31,10 +31,9 @@ library
3131 filepath -any,
3232 mtl >= 2.1.0 && < 2.3.0,
3333 parsec -any,
34− transformers >= 0.3 && < 0.5,
34+ transformers >= 0.4.0 && < 0.5,
3535 utf8-string >= 1 && < 2,
3636 pattern-arrows >= 0.0.2 && < 0.1,
37− monad-unify >= 0.2.2 && < 0.3,
3837 file-embed >= 0.0.7 && < 0.0.8,
3938 time -any
4039 exposed-modules: Language.PureScript
@@ -111,11 +110,13 @@ library
111110 Language.PureScript.TypeChecker.Unify
112111 Language.PureScript.TypeClassDictionaries
113112 Language.PureScript.Types
113+
114+ Control.Monad.Unify
114115 exposed: True
115116 buildable: True
116117 hs-source-dirs: src
117118 other-modules: Paths_purescript
118− ghc-options: -Wall -fno-warn-warnings-deprecations -O2
119+ ghc-options: -Wall -O2
119120
120121executable psc
121122 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
@@ -125,7 +126,7 @@ executable psc
125126 buildable: True
126127 hs-source-dirs: psc
127128 other-modules:
128− ghc-options: -Wall -fno-warn-warnings-deprecations -O2 -fno-warn-unused-do-bind
129+ ghc-options: -Wall -O2 -fno-warn-unused-do-bind
129130
130131executable psc-make
131132 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
@@ -135,7 +136,7 @@ executable psc-make
135136 buildable: True
136137 hs-source-dirs: psc-make
137138 other-modules:
138− ghc-options: -Wall -fno-warn-warnings-deprecations -O2 -fno-warn-unused-do-bind
139+ ghc-options: -Wall -O2 -fno-warn-unused-do-bind
139140
140141executable psci
141142 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
@@ -148,7 +149,7 @@ executable psci
148149 hs-source-dirs: psci
149150 other-modules: Commands
150151 Parser
151− ghc-options: -Wall -fno-warn-warnings-deprecations -O2
152+ ghc-options: -Wall -O2
152153
153154executable psc-docs
154155 build-depends: base >=4 && <5, purescript -any,
@@ -157,7 +158,7 @@ executable psc-docs
157158 buildable: True
158159 hs-source-dirs: psc-docs
159160 other-modules:
160− ghc-options: -Wall -fno-warn-warnings-deprecations -O2
161+ ghc-options: -Wall -O2
161162
162163executable psc-hierarchy
163164 build-depends: base >=4 && <5, purescript -any, optparse-applicative >= 0.10.0,
@@ -166,7 +167,7 @@ executable psc-hierarchy
166167 buildable: True
167168 hs-source-dirs: hierarchy
168169 other-modules:
169− ghc-options: -Wall -fno-warn-warnings-deprecations -O2
170+ ghc-options: -Wall -O2
170171
171172test-suite tests
172173 build-depends: base >=4 && <5, containers -any, directory -any,
src/Control/Monad/Unify.hsnew file+155
@@ -0,0 +1,155 @@
1+-----------------------------------------------------------------------------
2+--
3+-- Module : Control.Monad.Unify
4+-- Copyright : (c) Phil Freeman 2013
5+-- License : MIT
6+--
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
9+-- Portability :
10+--
11+-- |
12+--
13+--
14+-----------------------------------------------------------------------------
15+
16+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
17+{-# LANGUAGE FlexibleInstances #-}
18+{-# LANGUAGE FlexibleContexts #-}
19+{-# LANGUAGE DeriveDataTypeable #-}
20+{-# LANGUAGE MultiParamTypeClasses #-}
21+{-# LANGUAGE FunctionalDependencies #-}
22+{-# LANGUAGE UndecidableInstances #-}
23+{-# LANGUAGE OverloadedStrings #-}
24+
25+module Control.Monad.Unify where
26+
27+import Data.String (IsString)
28+import Data.Monoid
29+
30+import Control.Applicative
31+import Control.Monad.State
32+import Control.Monad.Error.Class
33+
34+import Data.HashMap.Strict as M
35+
36+-- |
37+-- Untyped unification variables
38+--
39+type Unknown = Int
40+
41+-- |
42+-- A type which can contain unification variables
43+--
44+class Partial t where
45+ unknown :: Unknown -> t
46+ isUnknown :: t -> Maybe Unknown
47+ unknowns :: t -> [Unknown]
48+ ($?) :: Substitution t -> t -> t
49+
50+-- |
51+-- Identifies types which support unification
52+--
53+class (Partial t) => Unifiable m t | t -> m where
54+ (=?=) :: t -> t -> UnifyT t m ()
55+
56+-- |
57+-- A substitution maintains a mapping from unification variables to their values
58+--
59+data Substitution t = Substitution { runSubstitution :: M.HashMap Int t }
60+
61+instance (Partial t) => Monoid (Substitution t) where
62+ mempty = Substitution M.empty
63+ s1 `mappend` s2 = Substitution $
64+ M.map (s2 $?) (runSubstitution s1) `M.union`
65+ M.map (s1 $?) (runSubstitution s2)
66+
67+-- |
68+-- State required for type checking
69+--
70+data UnifyState t = UnifyState {
71+ -- |
72+ -- The next fresh unification variable
73+ --
74+ unifyNextVar :: Int
75+ -- |
76+ -- The current substitution
77+ --
78+ , unifyCurrentSubstitution :: Substitution t
79+ }
80+
81+-- |
82+-- An empty @UnifyState@
83+--
84+defaultUnifyState :: (Partial t) => UnifyState t
85+defaultUnifyState = UnifyState 0 mempty
86+
87+-- |
88+-- The type checking monad, which provides the state of the type checker, and error reporting capabilities
89+--
90+newtype UnifyT t m a = UnifyT { unUnify :: (StateT (UnifyState t) m) a }
91+ deriving (Functor, Monad, Applicative, Alternative, MonadPlus)
92+
93+instance (MonadState s m) => MonadState s (UnifyT t m) where
94+ get = UnifyT . lift $ get
95+ put = UnifyT . lift . put
96+
97+instance (MonadError e m) => MonadError e (UnifyT t m) where
98+ throwError = UnifyT . throwError
99+ catchError e f = UnifyT $ catchError (unUnify e) (unUnify . f)
100+
101+-- |
102+-- Run a computation in the Unify monad, failing with an error, or succeeding with a return value and the new next unification variable
103+--
104+runUnify :: UnifyState t -> UnifyT t m a -> m (a, UnifyState t)
105+runUnify s = flip runStateT s . unUnify
106+
107+-- |
108+-- Substitute a single unification variable
109+--
110+substituteOne :: (Partial t) => Unknown -> t -> Substitution t
111+substituteOne u t = Substitution $ M.singleton u t
112+
113+-- |
114+-- Replace a unification variable with the specified value in the current substitution
115+--
116+(=:=) :: (IsString e, Monad m, MonadError e m, Unifiable m t) => Unknown -> t -> UnifyT t m ()
117+(=:=) u t' = do
118+ st <- UnifyT get
119+ let sub = unifyCurrentSubstitution st
120+ let t = sub $? t'
121+ occursCheck u t
122+ let current = sub $? unknown u
123+ case isUnknown current of
124+ Just u1 | u1 == u -> return ()
125+ _ -> current =?= t
126+ UnifyT $ modify $ \s -> s { unifyCurrentSubstitution = substituteOne u t <> unifyCurrentSubstitution s }
127+
128+-- |
129+-- Perform the occurs check, to make sure a unification variable does not occur inside a value
130+--
131+occursCheck :: (IsString e, Monad m, MonadError e m, Partial t) => Unknown -> t -> UnifyT t m ()
132+occursCheck u t =
133+ case isUnknown t of
134+ Nothing -> when (u `elem` unknowns t) $ UnifyT . lift . throwError $ "Occurs check fails"
135+ _ -> return ()
136+
137+-- |
138+-- Generate a fresh untyped unification variable
139+--
140+fresh' :: (Monad m) => UnifyT t m Unknown
141+fresh' = do
142+ st <- UnifyT get
143+ UnifyT $ modify $ \s -> s { unifyNextVar = succ (unifyNextVar s) }
144+ return $ unifyNextVar st
145+
146+-- |
147+-- Generate a fresh unification variable at a specific type
148+--
149+fresh :: (Monad m, Partial t) => UnifyT t m t
150+fresh = do
151+ u <- fresh'
152+ return $ unknown u
153+
154+
155+
src/Language/PureScript.hs+1−1
@@ -29,7 +29,7 @@ import qualified Data.Set as S
2929
3030import Control.Applicative
3131import Control.Arrow ((&&&))
32−import Control.Monad.Error
32+import Control.Monad.Except
3333import Control.Monad.Reader
3434
3535import System.FilePath ((</>))
src/Language/PureScript/Errors.hs+10−4
@@ -17,10 +17,11 @@
1717module Language.PureScript.Errors where
1818
1919import Data.Either (lefts, rights)
20+import Data.String (IsString(..))
2021import Data.List (intersperse, intercalate)
2122import Data.Monoid
2223
23−import Control.Monad.Error
24+import Control.Monad.Except
2425import Control.Applicative ((<$>))
2526
2627import Language.PureScript.AST
@@ -73,9 +74,14 @@ instance Monoid ErrorStack where
7374 mappend (MultipleErrors es) x = MultipleErrors [ e <> x | e <- es ]
7475 mappend x (MultipleErrors es) = MultipleErrors [ x <> e | e <- es ]
7576
76−instance Error ErrorStack where
77− strMsg s = ErrorStack [CompileError s Nothing Nothing]
78− noMsg = ErrorStack []
77+-- TODO: Remove strMsg, the IsString instance, and unnecessary
78+-- OverloadedStrings pragmas. See #745
79+-- | Create an ErrorStack from a string
80+strMsg :: String -> ErrorStack
81+strMsg s = ErrorStack [CompileError s Nothing Nothing]
82+
83+instance IsString ErrorStack where
84+ fromString = strMsg
7985
8086prettyPrintErrorStack :: Bool -> ErrorStack -> String
8187prettyPrintErrorStack printFullStack (ErrorStack es) =
src/Language/PureScript/ModuleDependencies.hs+1−1
@@ -19,7 +19,7 @@ module Language.PureScript.ModuleDependencies (
1919 ModuleGraph
2020) where
2121
22−import Control.Monad.Error.Class
22+import Control.Monad.Except
2323
2424import Data.Graph
2525import Data.List (nub)
src/Language/PureScript/Sugar/CaseDeclarations.hs+1−1
@@ -24,7 +24,7 @@ import Data.List (nub, groupBy)
2424
2525import Control.Applicative
2626import Control.Monad ((<=<), forM, join, unless, replicateM)
27−import Control.Monad.Error.Class
27+import Control.Monad.Except (throwError)
2828
2929import Language.PureScript.Names
3030import Language.PureScript.AST
src/Language/PureScript/Sugar/Names.hs+1−1
@@ -21,7 +21,7 @@ import Data.Maybe (fromMaybe, isJust, mapMaybe)
2121import Data.Monoid ((<>))
2222
2323import Control.Applicative (Applicative(..), (<$>), (<*>))
24−import Control.Monad.Error
24+import Control.Monad.Except
2525
2626import qualified Data.Map as M
2727
src/Language/PureScript/Sugar/Operators.hs+1−1
@@ -32,7 +32,7 @@ import Language.PureScript.Supply
3232
3333import Control.Applicative
3434import Control.Monad.State
35−import Control.Monad.Error.Class
35+import Control.Monad.Except
3636
3737import Data.Monoid ((<>))
3838import Data.Function (on)
src/Language/PureScript/Sugar/TypeClasses.hs+1−1
@@ -34,7 +34,7 @@ import qualified Language.PureScript.Constants as C
3434
3535import Control.Applicative
3636import Control.Arrow (first, second)
37−import Control.Monad.Error
37+import Control.Monad.Except
3838import Control.Monad.State
3939import Data.List ((\\), find)
4040import Data.Maybe (catMaybes, mapMaybe, isJust)
src/Language/PureScript/Sugar/TypeDeclarations.hs+1−1
@@ -22,8 +22,8 @@ module Language.PureScript.Sugar.TypeDeclarations (
2222import Data.Monoid ((<>))
2323
2424import Control.Applicative
25−import Control.Monad.Error.Class
2625import Control.Monad (forM)
26+import Control.Monad.Except (throwError)
2727
2828import Language.PureScript.AST
2929import Language.PureScript.Names
src/Language/PureScript/Supply.hs+1−1
@@ -24,7 +24,7 @@ import Data.Functor.Identity
2424
2525import Control.Applicative
2626import Control.Monad.State
27−import Control.Monad.Error.Class
27+import Control.Monad.Except
2828
2929newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a } deriving (Functor, Applicative, Monad, MonadTrans)
3030
src/Language/PureScript/TypeChecker.hs+1−1
@@ -32,7 +32,7 @@ import Data.Foldable (for_)
3232import qualified Data.Map as M
3333
3434import Control.Monad.State
35−import Control.Monad.Error
35+import Control.Monad.Except
3636
3737import Language.PureScript.Types
3838import Language.PureScript.Names
src/Language/PureScript/TypeChecker/Entailment.hs+2−1
@@ -25,9 +25,10 @@ import qualified Data.Map as M
2525
2626import Control.Applicative
2727import Control.Arrow (Arrow(..))
28−import Control.Monad.Error
28+import Control.Monad.Except
2929
3030import Language.PureScript.AST
31+import Language.PureScript.Errors
3132import Language.PureScript.Environment
3233import Language.PureScript.Names
3334import Language.PureScript.Pretty
src/Language/PureScript/TypeChecker/Kinds.hs+1−1
@@ -31,7 +31,7 @@ import qualified Data.Map as M
3131
3232import Control.Arrow (second)
3333import Control.Applicative
34−import Control.Monad.Error
34+import Control.Monad.Except
3535import Control.Monad.State
3636import Control.Monad.Unify
3737
src/Language/PureScript/TypeChecker/Monad.hs+7−7
@@ -14,7 +14,7 @@
1414-----------------------------------------------------------------------------
1515
1616{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances, RankNTypes,
17− MultiParamTypeClasses, FlexibleContexts #-}
17+ MultiParamTypeClasses, FlexibleContexts, GADTs #-}
1818
1919module Language.PureScript.TypeChecker.Monad where
2020
@@ -22,7 +22,7 @@ import Data.Maybe
2222import qualified Data.Map as M
2323
2424import Control.Applicative
25−import Control.Monad.Error
25+import Control.Monad.Except
2626import Control.Monad.Reader.Class
2727import Control.Monad.State
2828import Control.Monad.Unify
@@ -109,7 +109,7 @@ makeBindingGroupVisible action = do
109109-- |
110110-- Lookup the type of a value by name in the @Environment@
111111--
112−lookupVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m Type
112+lookupVariable :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m Type
113113lookupVariable currentModule (Qualified moduleName var) = do
114114 env <- getEnv
115115 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
@@ -119,7 +119,7 @@ lookupVariable currentModule (Qualified moduleName var) = do
119119-- |
120120-- Lookup the visibility of a value by name in the @Environment@
121121--
122−getVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m NameVisibility
122+getVisibility :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m NameVisibility
123123getVisibility currentModule (Qualified moduleName var) = do
124124 env <- getEnv
125125 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
@@ -129,7 +129,7 @@ getVisibility currentModule (Qualified moduleName var) = do
129129-- |
130130-- Assert that a name is visible
131131--
132−checkVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m ()
132+checkVisibility :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m ()
133133checkVisibility currentModule name@(Qualified _ var) = do
134134 vis <- getVisibility currentModule name
135135 case vis of
@@ -139,7 +139,7 @@ checkVisibility currentModule name@(Qualified _ var) = do
139139-- |
140140-- Lookup the kind of a type by name in the @Environment@
141141--
142−lookupTypeVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified ProperName -> m Kind
142+lookupTypeVariable :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified ProperName -> m Kind
143143lookupTypeVariable currentModule (Qualified moduleName name) = do
144144 env <- getEnv
145145 case M.lookup (Qualified (Just $ fromMaybe currentModule moduleName) name) (types env) of
@@ -172,7 +172,7 @@ data CheckState = CheckState {
172172-- The type checking monad, which provides the state of the type checker, and error reporting capabilities
173173--
174174newtype Check a = Check { unCheck :: StateT CheckState (Either ErrorStack) a }
175− deriving (Functor, Monad, Applicative, Alternative, MonadPlus, MonadState CheckState, MonadError ErrorStack)
175+ deriving (Functor, Monad, Applicative, MonadState CheckState, MonadError ErrorStack)
176176
177177-- |
178178-- Get the current @Environment@
src/Language/PureScript/TypeChecker/Rows.hs+1−1
@@ -19,7 +19,7 @@ module Language.PureScript.TypeChecker.Rows (
1919
2020import Data.List
2121
22−import Control.Monad.Error
22+import Control.Monad.Except
2323
2424import Language.PureScript.AST
2525import Language.PureScript.Errors
src/Language/PureScript/TypeChecker/Skolems.hs+1−1
@@ -26,7 +26,7 @@ import Data.List (nub, (\\))
2626import Data.Monoid
2727
2828import Control.Applicative
29−import Control.Monad.Error
29+import Control.Monad.Except
3030import Control.Monad.Unify
3131
3232import Language.PureScript.AST
src/Language/PureScript/TypeChecker/Subsumption.hs+1−1
@@ -22,7 +22,7 @@ import Data.Monoid
2222import Data.Ord (comparing)
2323
2424import Control.Applicative
25−import Control.Monad.Error
25+import Control.Monad.Except
2626import Control.Monad.Unify
2727
2828import Language.PureScript.AST
src/Language/PureScript/TypeChecker/Synonyms.hs+6−5
@@ -13,7 +13,7 @@
1313--
1414-----------------------------------------------------------------------------
1515
16−{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses #-}
16+{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, GADTs #-}
1717
1818module Language.PureScript.TypeChecker.Synonyms (
1919 saturateAllTypeSynonyms,
@@ -28,10 +28,11 @@ import Data.Maybe (fromMaybe)
2828import qualified Data.Map as M
2929
3030import Control.Applicative
31−import Control.Monad.Error
31+import Control.Monad.Except
3232import Control.Monad.State
3333
3434import Language.PureScript.Environment
35+import Language.PureScript.Errors
3536import Language.PureScript.Names
3637import Language.PureScript.TypeChecker.Monad
3738import Language.PureScript.Types
@@ -82,7 +83,7 @@ replaceAllTypeSynonyms' env d =
8283 in
8384 saturateAllTypeSynonyms syns d
8485
85−replaceAllTypeSynonyms :: (Error e, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
86+replaceAllTypeSynonyms :: (e ~ ErrorStack, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
8687replaceAllTypeSynonyms d = do
8788 env <- getEnv
8889 either (throwError . strMsg) return $ replaceAllTypeSynonyms' env d
@@ -98,12 +99,12 @@ expandTypeSynonym' env name args =
9899 replaceAllTypeSynonyms' env repl
99100 Nothing -> error "Type synonym was not defined"
100101
101−expandTypeSynonym :: (Error e, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Qualified ProperName -> [Type] -> m Type
102+expandTypeSynonym :: (e ~ ErrorStack, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Qualified ProperName -> [Type] -> m Type
102103expandTypeSynonym name args = do
103104 env <- getEnv
104105 either (throwError . strMsg) return $ expandTypeSynonym' env name args
105106
106−expandAllTypeSynonyms :: (Error e, Functor m, Applicative m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
107+expandAllTypeSynonyms :: (e ~ ErrorStack, Functor m, Applicative m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
107108expandAllTypeSynonyms = everywhereOnTypesTopDownM go
108109 where
109110 go (SaturatedTypeSynonym name args) = expandTypeSynonym name args
src/Language/PureScript/TypeChecker/Types.hs+5−4
@@ -13,7 +13,7 @@
1313--
1414-----------------------------------------------------------------------------
1515
16−{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses #-}
16+{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, OverloadedStrings #-}
1717
1818module Language.PureScript.TypeChecker.Types (
1919 typesOf
@@ -40,9 +40,10 @@ import Data.List
4040import Data.Maybe (fromMaybe)
4141import Data.Monoid
4242import qualified Data.Map as M
43+import Data.String (IsString)
4344
4445import Control.Applicative
45−import Control.Monad.Error
46+import Control.Monad.Except
4647import Control.Monad.State
4748import Control.Monad.Unify
4849
@@ -673,5 +674,5 @@ meet e1 e2 t1 t2 = do
673674-- |
674675-- Ensure a set of property names and value does not contain duplicate labels
675676--
676−ensureNoDuplicateProperties :: (Error e, MonadError e m) => [(String, Expr)] -> m ()
677−ensureNoDuplicateProperties ps = guardWith (strMsg "Duplicate property names") $ length (nub . map fst $ ps) == length ps
677+ensureNoDuplicateProperties :: (IsString e, MonadError e m) => [(String, Expr)] -> m ()
678+ensureNoDuplicateProperties ps = guardWith "Duplicate property names" $ length (nub . map fst $ ps) == length ps
src/Language/PureScript/TypeChecker/Unify.hs+1−1
@@ -30,7 +30,7 @@ import Data.Maybe (fromMaybe)
3030import Data.Monoid
3131import qualified Data.HashMap.Strict as H
3232
33−import Control.Monad.Error
33+import Control.Monad.Except
3434import Control.Monad.Unify
3535
3636import Language.PureScript.Environment