Skip to content

Commit

Permalink
Support generic SinkableK for equality constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
fizruk committed Oct 28, 2024
1 parent 0f0a3ab commit 6f499f1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions haskell/free-foil/src/Control/Monad/Foil/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import Data.Bifunctor
import Generics.Kind
import Unsafe.Coerce
import GHC.TypeError
import qualified Type.Reflection as Type

-- * Safe types and operations

Expand Down Expand Up @@ -1244,11 +1245,9 @@ instance GenericK U2 where
toK (SuchThat U1) = U2
fromK U2 = SuchThat U1

instance SinkableK NameBinderList where
sinkabilityProofK _ _ _ = undefined
instance SinkableK NameBinderList
instance SinkableK V2
instance SinkableK U2 where
sinkabilityProofK _ _ _ = undefined
instance SinkableK U2

sinkabilityProof1 :: SinkableK f => (Name n -> Name n') -> f n -> f n'
sinkabilityProof1 rename e = sinkabilityProofK (RCons rename RNil) e $ \_ e' -> unsafeCoerce e'
Expand Down Expand Up @@ -1302,10 +1301,12 @@ instance GSinkableK f => GSinkableK (Exists S f) where
gsinkabilityProofK (RCons id irename) x $ \(RCons _ irename') x' ->
cont irename' (Exists x')

-- instance GSinkableK f => GSinkableK (c :=>: f) where
-- gsinkabilityProofK irename (SuchThat x) cont =
-- gsinkabilityProofK irename x $ \irename' x' ->
-- cont irename' (SuchThat x')
instance GSinkableK f => GSinkableK (((~) :$: a :@: b) :=>: f) where
gsinkabilityProofK irename (SuchThat x) cont =
gsinkabilityProofK irename x $ \irename' x' ->
-- this is sort of safe...
case unsafeCoerce (Type.Refl :: a Type.:~: a) :: a Type.:~: b of
Type.Refl -> cont irename' (SuchThat x')

instance GSinkableK (Field (Kon a)) where
gsinkabilityProofK irename (Field x) cont =
Expand Down

0 comments on commit 6f499f1

Please sign in to comment.