git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #2362, treat type annotations on top-level expressions as if they were type declarations (#2366)
12ec934Phil Freeman
src/Language/PureScript/TypeChecker/Entailment.hs−1
@@ -233,7 +233,6 @@ entails shouldGeneralize deferErrors (TypeClassDictionary constraint context hin
233
233
234 canBeGeneralized :: Type -> Bool
234 canBeGeneralized :: Type -> Bool
235 canBeGeneralized TUnknown{} = True
235 canBeGeneralized TUnknown{} = True
236− canBeGeneralized Skolem{} = True
237 canBeGeneralized _ = False
236 canBeGeneralized _ = False
238
237
239 -- |
238 -- |
src/Language/PureScript/TypeChecker/Types.hs+6
@@ -27,12 +27,14 @@ module Language.PureScript.TypeChecker.Types
27
27
28import Prelude.Compat
28import Prelude.Compat
29
29
30+import Control.Arrow (second)
30import Control.Monad
31import Control.Monad
31import Control.Monad.Error.Class (MonadError(..))
32import Control.Monad.Error.Class (MonadError(..))
32import Control.Monad.State.Class (MonadState(..), gets)
33import Control.Monad.State.Class (MonadState(..), gets)
33import Control.Monad.Supply.Class (MonadSupply)
34import Control.Monad.Supply.Class (MonadSupply)
34import Control.Monad.Writer.Class (MonadWriter(..))
35import Control.Monad.Writer.Class (MonadWriter(..))
35
36
37+import Data.Bifunctor (bimap)
36import Data.Either (lefts, rights)
38import Data.Either (lefts, rights)
37import Data.List (transpose, nub, (\\), partition, delete)
39import Data.List (transpose, nub, (\\), partition, delete)
38import Data.Maybe (fromMaybe)
40import Data.Maybe (fromMaybe)
@@ -199,6 +201,10 @@ typeForBindingGroupElement (ident, val) dict untypedDict = do
199-- | Check if a value contains a type annotation
201-- | Check if a value contains a type annotation
200isTyped :: (Ident, Expr) -> Either (Ident, Expr) (Ident, (Expr, Type, Bool))
202isTyped :: (Ident, Expr) -> Either (Ident, Expr) (Ident, (Expr, Type, Bool))
201isTyped (name, TypedValue checkType value ty) = Right (name, (value, ty, checkType))
203isTyped (name, TypedValue checkType value ty) = Right (name, (value, ty, checkType))
204+isTyped (name, PositionedValue pos c value) =
205+ bimap (second (PositionedValue pos c))
206+ (second (\(e, t, b) -> (PositionedValue pos c e, t, b)))
207+ (isTyped (name, value))
202isTyped (name, value) = Left (name, value)
208isTyped (name, value) = Left (name, value)
203
209
204-- |
210-- |