Skip to content

Instantly share code, notes, and snippets.

@lotz84
Created October 9, 2016 07:52
Show Gist options
  • Save lotz84/a69326407418f35f4b64b7387a023fd7 to your computer and use it in GitHub Desktop.
Save lotz84/a69326407418f35f4b64b7387a023fd7 to your computer and use it in GitHub Desktop.
Line 10 is correct but line 11 is incorrect.
{-# LANGUAGE RankNTypes #-}
action :: ((forall s. s -> s) -> IO ()) -> IO ()
action f = f id
f :: (forall s. s -> s) -> ()
f _ = ()
main = do
action (\x -> pure $ f x)
action (pure . f)
$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
$ stack runghc Main.hs
Main.hs:11:18: error:
• Couldn't match type ‘s0 -> s0’ with ‘forall s. s -> s’
Expected type: (s0 -> s0) -> ()
Actual type: (forall s. s -> s) -> ()
• In the second argument of ‘(.)’, namely ‘f’
In the first argument of ‘action’, namely ‘(pure . f)’
In a stmt of a 'do' block: action (pure . f)
@lotz84
Copy link
Author

lotz84 commented Oct 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment