Skip to content

Instantly share code, notes, and snippets.

@jvans1
Created May 23, 2015 17:20
Show Gist options
  • Save jvans1/4db8a96575b34387a6c9 to your computer and use it in GitHub Desktop.
Save jvans1/4db8a96575b34387a6c9 to your computer and use it in GitHub Desktop.
ScopedTypeVariables
--#This code blows up
myFunction :: Ord a => [a] -> [a]
myFunction inputArray = reversedArray where
reversedArray :: Ord a => [a]
reversedArray = reverse inputArray
main :: IO ()
main = print $ myFunction [1,2,3]
--#Below code works
{-# LANGUAGE ScopedTypeVariables #-}
myFunction :: forall a. Ord a => [a] -> [a]
myFunction inputArray = reversedArray where
reversedArray :: Ord a => [a]
reversedArray = reverse inputArray
main :: IO ()
main = print $ myFunction [1,2,3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment