cartazio / omega

Automatically exported from code.google.com/p/omega
Other
4 stars 0 forks source link

function returning pair with higher-rank type does not typecheck #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. load this simple program

---------------------
data A = A (forall x. x -> x, Int)
--data A = A (A -> A, Int)

--f3 :: A -> (forall x. x -> x, Int)
f3 (A (c@(a, b))) = c
--f3 (A c) = c

---------------------

2. observe error:

**** Near File: impred.prg
line: 5 column: 1
Pattern match failure in do expression at Infer.hs:1632:25-30

3. not using higher-rank structure as return value resolves the problem.
also supplying a type signature resolves te problem.

What is the expected output? What do you see instead?

The error message is inacceptable, we should urge the user to supply a type 
signature for f3.

What does Haskell (GHC?) say in this situation?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by ggr...@gmail.com on 10 Aug 2011 at 8:53

Attachments:

GoogleCodeExporter commented 8 years ago
The attachment contains some diagnostics and hints at a possible solution.

Original comment by ggr...@gmail.com on 10 Aug 2011 at 8:55

GoogleCodeExporter commented 8 years ago
This Haskell program:

$ cat impred.hs
module Foo where

data A = A (forall x. x -> x, Int)

--f3 :: A -> (forall x. x -> x, Int)
f3 (A (c@(a, b))) = c

Compiles with "ghc -XImpredicativeTypes impred.hs", with or without the type 
signature.

Original comment by ggr...@gmail.com on 10 Aug 2011 at 9:11

GoogleCodeExporter commented 8 years ago
r766 nudges the user towards using a type signature.

Original comment by ggr...@gmail.com on 10 Aug 2011 at 9:45