[PL-sem-jr] Next Wednesday (5/18): Winskel Ch 5 discussion (5:30pm, WVH 366)
Benjamin Greenman
types at ccs.neu.edu
Thu May 12 02:03:13 EDT 2016
RE: today's discussion of when Haskell's type inference fails, here a
little program that won't compile
foo f a b = f (bar a) (bar b)
bar x = if x <= 1 then x else foo (+) (x - 1) (x - 2)
main = return $ foo (\ x y -> ()) 1 2
The error message is about the return type of foo. Haskell wants (+) to
return something compatible with the Unit type.
The problem is that unification breaks down for higher-order polymorphic
types.
OCaml has the same problem (attached, with comments by Drew Weymouth -- who
wrote the original program).
It's not a bug. We were just worried at the time.
(A smaller Haskell program that type inference fails on is `main = return $
read "1"` )
On Wed, May 11, 2016 at 6:25 PM, Sam Caldwell <samc at ccs.neu.edu> wrote:
> read and bring your questions!
>
> _______________________________________________
> Pl-sem-jr mailing list
> Pl-sem-jr at lists.ccs.neu.edu
> https://lists.ccs.neu.edu/bin/listinfo/pl-sem-jr
>
>
-------------- next part --------------
HTML attachment scrubbed and removed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ocaml_bug.ml
Type: application/octet-stream
Size: 1204 bytes
Desc: not available
URL: <http://lists.ccs.neu.edu/pipermail/pl-sem-jr/attachments/20160512/8e143f9d/attachment.obj>
More information about the Pl-sem-jr
mailing list