Skip to content

Instantly share code, notes, and snippets.

@jvranish
Created June 13, 2010 22:47
Show Gist options
  • Save jvranish/437064 to your computer and use it in GitHub Desktop.
Save jvranish/437064 to your computer and use it in GitHub Desktop.
import Data.Maybe
-- The fixed point datatype
data Y f = Y (f (Y f))
-- dummy function for illustration
maybeToInt :: Maybe a -> Int
maybeToInt = length . maybeToList
f :: Y Maybe -> Int
f (Y x) = g maybeToInt x
-- This is the type it wants to infer
-- g :: (Maybe Int -> Int) -> Maybe (Y Maybe) -> Int
-- This is the type I think it should have, note you can't force
-- with typesig without -XRelaxedPolyRec
-- g :: (Functor f) => (f Int -> b) -> f (Y Maybe) -> b
g h x = h $ fmap f x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment