Skip to content

Instantly share code, notes, and snippets.

@roboguy13
Last active November 4, 2017 02:22
Show Gist options
  • Save roboguy13/9fabafa92c8e85501034139687faffb7 to your computer and use it in GitHub Desktop.
Save roboguy13/9fabafa92c8e85501034139687faffb7 to your computer and use it in GitHub Desktop.
{-# LANGUAGE RankNTypes #-}
exampleA :: [a] -> [a]
exampleA = reverse
exampleB :: [Int] -> [Int]
exampleB = filter even
rank2 :: (forall a. [a] -> [a]) -> [Char]
rank2 f = f "abc"
-- 'rank2 exampleA' compiles and gives the result "cba"
-- 'rank2 exampleB' does not type check, because 'exampleB' does not work "for all 'a' types"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment