Skip to content

Instantly share code, notes, and snippets.

@exterm
Last active December 14, 2015 03:59
Show Gist options
  • Select an option

  • Save exterm/5024877 to your computer and use it in GitHub Desktop.

Select an option

Save exterm/5024877 to your computer and use it in GitHub Desktop.
Haskell underestimates parameter types and overestimates return types.
and _ False = False
and False _ = False
and _ _ = True
-- inferred type: Bool -> Bool -> Bool
-- underestimated parameter type: the function would also work called like this:
and 42 False
-- and return False; the type checker throws an error for this though.
and' _ False = 0
and' False _ = 0
and' _ _ = 1
-- inferred type: Num a => Bool -> Bool -> a
-- but no values other than 0 or 1 can be returned. The return type could theoretically be 0 | 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment