Last active
March 20, 2020 10:04
-
-
Save chrisdone/42e396fefab7be77c2f7244d3319565f to your computer and use it in GitHub Desktop.
Data.Functor.NormalizedConstrained.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
| {-# LANGUAGE RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds #-} | |
| -- Paper: http://neilsculthorpe.com/publications/constrained-monad-problem.pdf | |
| -- Talk: https://vimeo.com/69261960 | |
| import GHC.Exts | |
| data NF :: (* -> Constraint) -> (* -> *) -> * -> * where | |
| FMap :: c x => (x -> a) -> t x -> NF c t a | |
| instance Functor (NF c t) where | |
| fmap :: (a -> b) -> NF c t a -> NF c t b | |
| fmap g (FMap h tx) = FMap (g . h) tx | |
| liftNF :: c a => t a -> NF c t a | |
| liftNF ta = FMap id ta | |
| lowerNF :: (forall x. c x => (x -> a) -> t x -> t a) -> NF c t a -> t a | |
| lowerNF fmp (FMap g tx) = fmp g tx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment