Created
December 3, 2011 05:32
-
-
Save takeouchida/1426173 to your computer and use it in GitHub Desktop.
An example of missing some kinds of type constraints.
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
module Lookup where | |
import Prelude hiding (lookup) | |
lookup :: a -> [(a, b)] -> Maybe b -- valid if the type a is a kind of Eq instances | |
lookup k [] = Nothing | |
lookup k ((k', v):ls) = if k == k' then Just v else lookup k ls |
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
Lookup.hs:7:30: | |
No instance for (Eq a) | |
arising from a use of `==' | |
In the expression: k == k' | |
In the expression: if k == k' then Just v else lookup k ls | |
In an equation for `lookup': | |
lookup k ((k', v) : ls) = if k == k' then Just v else lookup k ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment