Skip to content

Commit

Permalink
Preserve inner exists/forall (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
gardspirito authored Aug 15, 2023
1 parent 5f52907 commit cd70563
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Grace/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ subtype _A0 _B0 = do
-- except with the arguments flipped. Similarly, the <:∃L rule is
-- basically the same as the <:∀R rule with the arguments flipped.

-- <:∃L
(Type.Exists{..}, _) -> do
scoped (Context.Variable domain name) do
subtype type_ _B0

-- <:∀R
(_, Type.Forall{..}) -> do
scoped (Context.Variable domain name) do
subtype _A0 type_

-- <:∃R
(_, Type.Exists{ domain = Domain.Type, .. }) -> do
scopedUnsolvedType nameLocation \a ->
Expand All @@ -339,16 +349,6 @@ subtype _A0 _B0 = do
scopedUnsolvedAlternatives \a -> do
subtype (Type.substituteAlternatives name 0 a type_) _B0

-- <:∃L
(Type.Exists{..}, _) -> do
scoped (Context.Variable domain name) do
subtype type_ _B0

-- <:∀R
(_, Type.Forall{..}) -> do
scoped (Context.Variable domain name) do
subtype _A0 type_

(Type.Scalar{ scalar = s0 }, Type.Scalar{ scalar = s1 })
| s0 == s1 -> do
return ()
Expand Down
4 changes: 4 additions & 0 deletions tasty/data/complex/preserve-inner-exists-input.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let wrappedVal
: { wrapped : exists (a : Type). a }
= { wrapped : 0 }
in wrappedVal : { wrapped: exists (a : Type). a }
1 change: 1 addition & 0 deletions tasty/data/complex/preserve-inner-exists-output.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "wrapped": 0 }
1 change: 1 addition & 0 deletions tasty/data/complex/preserve-inner-exists-type.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ wrapped: exists (a : Type) . a }
4 changes: 4 additions & 0 deletions tasty/data/complex/preserve-inner-forall-input.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let wrappedId
: { wrapped : forall (a : Type). a -> a }
= { wrapped : \x -> x }
in wrappedId : { wrapped: forall (a : Type). a -> a }
1 change: 1 addition & 0 deletions tasty/data/complex/preserve-inner-forall-output.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "wrapped": \x -> x }
1 change: 1 addition & 0 deletions tasty/data/complex/preserve-inner-forall-type.ffg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ wrapped: forall (a : Type) . a -> a }

0 comments on commit cd70563

Please sign in to comment.