Skip to content

Commit 806a49f

Browse files
committed
Fix Type.resultType and Type.arity to work properly in spite of effects
1 parent 71f25f8 commit 806a49f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

unison-core/src/Unison/Type.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ arity :: Type v a -> Int
102102
arity (ForallNamed' _ body) = arity body
103103
arity (Arrow' _ o) = 1 + arity o
104104
arity (Ann' a _) = arity a
105+
arity (Effect' _ o) = arity o
105106
arity _ = 0
106107

107108
-- some smart patterns
@@ -142,7 +143,7 @@ pattern Effects' es <- ABT.Tm' (Effects es)
142143
pattern Effect1' :: ABT.Term F v a -> ABT.Term F v a -> ABT.Term F v a
143144
pattern Effect1' e t <- ABT.Tm' (Effect e t)
144145

145-
pattern Effect' :: (Ord v) => [Type v a] -> Type v a -> Type v a
146+
pattern Effect' :: [Type v a] -> Type v a -> Type v a
146147
pattern Effect' es t <- (unEffects1 -> Just (es, t))
147148

148149
pattern Effect'' :: (Ord v) => [Type v a] -> Type v a -> Type v a
@@ -242,7 +243,7 @@ unEffect0 :: (Ord v) => Type v a -> ([Type v a], Type v a)
242243
unEffect0 (Effect1' e a) = (flattenEffects e, a)
243244
unEffect0 t = ([], t)
244245

245-
unEffects1 :: (Ord v) => Type v a -> Maybe ([Type v a], Type v a)
246+
unEffects1 :: Type v a -> Maybe ([Type v a], Type v a)
246247
unEffects1 (Effect1' (Effects' es) a) = Just (es, a)
247248
unEffects1 _ = Nothing
248249

@@ -756,6 +757,7 @@ functionResult = go False
756757
where
757758
go inArr (ForallNamed' _ body) = go inArr body
758759
go _inArr (Arrow' _i o) = go True o
760+
go _inArr (Effect1' _e body) = go True body
759761
go inArr t = if inArr then Just t else Nothing
760762

761763
-- | Bind all free variables (not in `except`) that start with a lowercase

0 commit comments

Comments
 (0)