Created
February 22, 2013 02:09
-
-
Save kyagrd/5010208 to your computer and use it in GitHub Desktop.
DeriveFunctor works with RankNTypes in GHC
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 DeriveFunctor, RankNTypes, StandaloneDeriving #-} | |
-- The Glorious Glasgow Haskell Compilation System, version 7.4.1 | |
data F x = C (([x] -> Bool) -> Maybe x) deriving Functor | |
data F1 x = C1 ((forall y . [(y,x)] -> y) -> Maybe x) deriving Functor | |
data F2 x = C2 (forall y . ([x] -> y) -> [(y,x)]) deriving Functor | |
data F3 x = C3 (forall y . ([x] -> y) -> Maybe y) deriving Functor | |
data F4 x = C4 (forall y . ([x] -> y) -> (y,x)) deriving Functor | |
deriving instance Functor ((,) y) | |
-- instance Functor F where | |
-- fmap f (C g) = C (\h -> fmap f (g (h . fmap f))) | |
-- instance Functor F1 where | |
-- fmap f (C1 g) = C1 (\h -> fmap f (g (h . fmap (fmap f)))) | |
-- instance Functor F2 where | |
-- fmap f (C2 g) = C2 (\h -> fmap (fmap f) (g (h . fmap f))) | |
-- instance Functor F3 where | |
-- fmap f (C3 g) = C3 (\h -> (g (h . fmap f))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment