Created
October 2, 2025 11:21
-
-
Save chrisdone-artificial/820ef652c6860fb5ffb8031759ebe3e9 to your computer and use it in GitHub Desktop.
sweet.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| newtype L c t = L (forall e. Dict (c (t e))) | |
| withL :: forall c t r. L c t -> (forall e. Dict (c (t e)) -> r) -> r | |
| withL (L dict) r = r dict | |
| functorEitherL :: L Functor Either | |
| functorEitherL = L Dict | |
| someFuntorEitherL :: Dynamic | |
| someFuntorEitherL = toDyn functorEitherL | |
| getItBack :: Dynamic -> TypeRep (L c t) -> Maybe (L c t) | |
| getItBack (Dynamic rep a) l_t = | |
| case rep of | |
| _ | Just Type.HRefl <- Type.eqTypeRep l_t rep | |
| -> Just a | |
| _ -> Nothing | |
| applyClass :: Dynamic -> TypeRep (L c t) -> | |
| (forall e. Dict (c (t e)) -> r) -> Maybe r | |
| applyClass dyn l_t f = do | |
| l <- getItBack dyn l_t | |
| pure $ withL l f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment