22module Analysis.Typecheck
33( Monotype (.. )
44, Meta
5- , Polytype (PForAll , PBool , PFree , PArr )
5+ , Polytype (PForAll , PBool , PArr )
66, Scope
77, typecheckingFlowInsensitive
88, typecheckingAnalysis
@@ -52,8 +52,6 @@ data Polytype f a
5252 | PUnit
5353 | PBool
5454 | PString
55- | PBound Int
56- | PFree Gensym
5755 | PArr (f a ) (f a )
5856 | PRecord (Map. Map User (f a ))
5957 deriving (Foldable , Functor , Generic1 , Traversable )
@@ -64,8 +62,6 @@ instance RightModule Polytype where
6462 PUnit >>=* _ = PUnit
6563 PBool >>=* _ = PBool
6664 PString >>=* _ = PString
67- PBound i >>=* _ = PBound i
68- PFree n >>=* _ = PFree n
6965 PArr a b >>=* f = PArr (a >>= f) (b >>= f)
7066 PRecord m >>=* f = PRecord ((>>= f) <$> m)
7167
@@ -80,13 +76,13 @@ generalize :: (Carrier sig m, Member Naming sig) => Monotype Meta -> m (Term Pol
8076generalize ty = namespace " generalize" $ do
8177 Gensym root _ <- Name. fresh
8278 pure (forAlls (map (Gensym root) (IntSet. toList (mvs ty))) (fold root ty))
83- where fold root = Term . \ case
84- MUnit -> PUnit
85- MBool -> PBool
86- MString -> PString
87- MMeta i -> PFree (Gensym root i)
88- MArr a b -> PArr (fold root a) (fold root b)
89- MRecord fs -> PRecord (fold root <$> fs)
79+ where fold root = \ case
80+ MUnit -> Term PUnit
81+ MBool -> Term PBool
82+ MString -> Term PString
83+ MMeta i -> Var (Gensym root i)
84+ MArr a b -> Term ( PArr (fold root a) (fold root b) )
85+ MRecord fs -> Term ( PRecord (fold root <$> fs) )
9086
9187
9288typecheckingFlowInsensitive :: [File (Term Core. Core Name )] -> (Heap Name (Monotype Meta ), [File (Either (Loc , String ) (Term Polytype Gensym ))])
0 commit comments