Skip to content

Instantly share code, notes, and snippets.

@takeouchida
Created December 3, 2011 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeouchida/1426173 to your computer and use it in GitHub Desktop.
Save takeouchida/1426173 to your computer and use it in GitHub Desktop.
An example of missing some kinds of type constraints.
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
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