Created
May 23, 2015 17:20
-
-
Save jvans1/4db8a96575b34387a6c9 to your computer and use it in GitHub Desktop.
ScopedTypeVariables
This file contains 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
--#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