type IsString + test unification error
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE QuasiQuotes, OverloadedStrings #-}
|
||||
module Core.HindleyMilnerSpec
|
||||
( spec
|
||||
)
|
||||
@@ -6,7 +6,7 @@ module Core.HindleyMilnerSpec
|
||||
----------------------------------------------------------------------------------
|
||||
import Core.Syntax
|
||||
import Core.TH (coreExpr)
|
||||
import Core.HindleyMilner (infer)
|
||||
import Core.HindleyMilner (infer, TypeError(..), HMError)
|
||||
import Test.Hspec
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
@@ -14,6 +14,14 @@ import Test.Hspec
|
||||
spec :: Spec
|
||||
spec = do
|
||||
it "should infer `id 3` :: Int" $
|
||||
let g = [ ("id", TyVar "a" :-> TyVar "a") ]
|
||||
let g = [ ("id", "a" :-> "a") ]
|
||||
in infer g [coreExpr|id 3|] `shouldBe` Right TyInt
|
||||
|
||||
it "should not infer `id 3` when `id` is specialised to `a -> a`" $
|
||||
let g = [ ("id", ("a" :-> "a") :-> "a" :-> "a") ]
|
||||
in infer g [coreExpr|id 3|] `shouldSatisfy` isUntypedVariableErr
|
||||
|
||||
isUntypedVariableErr :: HMError a -> Bool
|
||||
isUntypedVariableErr (Left (TyErrCouldNotUnify _ _)) = True
|
||||
isUntypedVariableErr _ = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user