@@ -2,9 +2,8 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Type.Constraint
3module Type.Constraint
4 ( Constraint(..)
4 ( Constraint(..)
5− , (/\), ex, forall
5+ , ex
6− , exists, existsNumber
7− , Scheme(..), SchemeName
6+ , Scheme(..)
8 , monoscheme
7 , monoscheme
@@ -12,11 +11,12 @@ module Type.Constraint
13import qualified Data.Map.Strict as Map
12import qualified Data.Map.Strict as Map
14+import qualified AST.Canonical as Can
15import qualified Elm.Name as N
15import qualified Elm.Name as N
16import qualified Reporting.Annotation as A
16import qualified Reporting.Annotation as A
17import qualified Reporting.Error.Type as Error
17import qualified Reporting.Error.Type as Error
18import qualified Reporting.Region as R
18import qualified Reporting.Region as R
19−import Type.Type (Type(VarN), Variable, mkFlexVar, mkFlexNumber)
19+import Type.Type (Type, Variable)
@@ -25,26 +25,25 @@ import Type.Type (Type(VarN), Variable, mkFlexVar, mkFlexNumber)
26data Constraint
26data Constraint
28− | CSaveEnv
28+ | CSaveHeaders
29− | CEqual Error.Hint R.Region Type Type
29+ | CEqual R.Region Error.Context Error.Category R.Region Type Type
30+ | CLookup R.Region Error.Context R.Region N.Name Type
31+ | CInstance R.Region Error.Context R.Region Can.Type Type
32+ | CPattern R.Region Error.PatternContext Error.PatternCategory R.Region Type Type
30 | CAnd [Constraint]
33 | CAnd [Constraint]
31 | CLet [Scheme] Constraint
34 | CLet [Scheme] Constraint
32− | CInstance R.Region SchemeName Type
39−type SchemeName = N.Name
42data Scheme =
41data Scheme =
44− { _rigidQuantifiers :: [Variable]
43+ { _rigidVars :: [Variable]
45− , _flexibleQuantifiers :: [Variable]
44+ , _flexVars :: [Variable]
46− , _constraint :: Constraint
47 , _header :: Map.Map N.Name (A.Located Type)
45 , _header :: Map.Map N.Name (A.Located Type)
46+ , _constraint :: Constraint
@@ -54,42 +53,17 @@ data Scheme =
55monoscheme :: Map.Map N.Name (A.Located Type) -> Scheme
54monoscheme :: Map.Map N.Name (A.Located Type) -> Scheme
56monoscheme headers =
55monoscheme headers =
57− Scheme [] [] CTrue headers
56+ Scheme [] [] headers CTrue
61-- CONSTRAINT HELPERS
60-- CONSTRAINT HELPERS
67−(/\) :: Constraint -> Constraint -> Constraint
75-- ex qs constraint == exists qs. constraint
63-- ex qs constraint == exists qs. constraint
76ex :: [Variable] -> Constraint -> Constraint
64ex :: [Variable] -> Constraint -> Constraint
77−ex fqs constraint =
65+ex flexVars constraint =
78− CLet [Scheme [] fqs constraint Map.empty] CTrue
66+ CLet
81−forall :: [Variable] -> Constraint -> Constraint
82−forall rqs constraint =
83− CLet [Scheme rqs [] constraint Map.empty] CTrue
67+ [ Scheme [] flexVars Map.empty constraint
86−exists :: (Type -> IO Constraint) -> IO Constraint
89− ex [v] <$> f (VarN v)
92−existsNumber :: (Type -> IO Constraint) -> IO Constraint
95− ex [v] <$> f (VarN v)