Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 3e7123f

Browse files
committed
🔥 the M prefixes on Monotype’s constructors.
1 parent b81cbf2 commit 3e7123f

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

semantic-core/src/Analysis/Typecheck.hs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import GHC.Generics (Generic1)
3737
import Prelude hiding (fail)
3838

3939
data Monotype f a
40-
= MBool
41-
| MUnit
42-
| MString
43-
| MArr (f a) (f a)
44-
| MRecord (Map.Map User (f a))
40+
= Bool
41+
| Unit
42+
| String
43+
| Arr (f a) (f a)
44+
| Record (Map.Map User (f a))
4545
deriving (Foldable, Functor, Generic1, Traversable)
4646

4747
deriving instance (Eq a, forall a . Eq a => Eq (f a), Monad f) => Eq (Monotype f a)
@@ -51,11 +51,11 @@ deriving instance (Show a, forall a . Show a => Show (f a)) => Show (Mo
5151

5252
instance HFunctor Monotype
5353
instance RightModule Monotype where
54-
MUnit >>=* _ = MUnit
55-
MBool >>=* _ = MBool
56-
MString >>=* _ = MString
57-
MArr a b >>=* f = MArr (a >>= f) (b >>= f)
58-
MRecord m >>=* f = MRecord ((>>= f) <$> m)
54+
Unit >>=* _ = Unit
55+
Bool >>=* _ = Bool
56+
String >>=* _ = String
57+
Arr a b >>=* f = Arr (a >>= f) (b >>= f)
58+
Record m >>=* f = Record ((>>= f) <$> m)
5959

6060
type Meta = Int
6161

@@ -96,11 +96,11 @@ generalize ty = namespace "generalize" $ do
9696
where fold root = \case
9797
Var v -> pure (Gensym root v)
9898
Term t -> Term $ case t of
99-
MUnit -> PUnit
100-
MBool -> PBool
101-
MString -> PString
102-
MArr a b -> PArr (fold root a) (fold root b)
103-
MRecord fs -> PRecord (fold root <$> fs)
99+
Unit -> PUnit
100+
Bool -> PBool
101+
String -> PString
102+
Arr a b -> PArr (fold root a) (fold root b)
103+
Record fs -> PRecord (fold root <$> fs)
104104

105105

106106
typecheckingFlowInsensitive :: [File (Term Core.Core Name)] -> (Heap Name (Term Monotype Meta), [File (Either (Loc, String) (Term Polytype Gensym))])
@@ -152,18 +152,18 @@ typecheckingAnalysis = Analysis{..}
152152
arg <- meta
153153
assign addr arg
154154
ty <- eval body
155-
pure (Term (MArr arg ty))
155+
pure (Term (Arr arg ty))
156156
apply _ f a = do
157157
_A <- meta
158158
_B <- meta
159-
unify (Term (MArr _A _B)) f
159+
unify (Term (Arr _A _B)) f
160160
unify _A a
161161
pure _B
162-
unit = pure (Term MUnit)
163-
bool _ = pure (Term MBool)
164-
asBool b = unify (Term MBool) b >> pure True <|> pure False
165-
string _ = pure (Term MString)
166-
asString s = unify (Term MString) s $> mempty
162+
unit = pure (Term Unit)
163+
bool _ = pure (Term Bool)
164+
asBool b = unify (Term Bool) b >> pure True <|> pure False
165+
string _ = pure (Term String)
166+
asString s = unify (Term String) s $> mempty
167167
frame = fail "unimplemented"
168168
edge _ _ = pure ()
169169
_ ... m = m
@@ -194,8 +194,8 @@ solve :: (Carrier sig m, Member (State Substitution) sig, MonadFail m) => Set.Se
194194
solve cs = for_ cs solve
195195
where solve = \case
196196
-- FIXME: how do we enforce proper subtyping? row polymorphism or something?
197-
Term (MRecord f1) :===: Term (MRecord f2) -> traverse solve (Map.intersectionWith (:===:) f1 f2) $> ()
198-
Term (MArr a1 b1) :===: Term (MArr a2 b2) -> solve (a1 :===: a2) *> solve (b1 :===: b2)
197+
Term (Record f1) :===: Term (Record f2) -> traverse solve (Map.intersectionWith (:===:) f1 f2) $> ()
198+
Term (Arr a1 b1) :===: Term (Arr a2 b2) -> solve (a1 :===: a2) *> solve (b1 :===: b2)
199199
Var m1 :===: Var m2 | m1 == m2 -> pure ()
200200
Var m1 :===: t2 -> do
201201
sol <- solution m1

0 commit comments

Comments
 (0)