[Haskell-cafe] Implicit newtype unwrapping
Joachim Breitner
mail at joachim-breitner.de
Thu Dec 3 05:31:50 EST 2009
Hi,
Am Donnerstag, den 03.12.2009, 11:25 +0100 schrieb Sjoerd Visscher:
> Hmm, as long as you provide a type signature, Haskell could do implicit wrapping as well.
>
> If I'm not mistaken, the compiler should be able to figure out what to do in this case:
> > myfoo :: (Blubb -> MyFoo) -> MyFoo -> MyFoo -> MyFoo
> > myfoo = foo
Maybe it should, but it does not:
$ cat test.hs
data Foo = Foo
newtype MyFoo = MyFoo { unMyFoo :: Foo }
foo :: Foo -> (() -> Foo) -> Foo
foo Foo f = Foo
myfoo :: MyFoo -> (() -> MyFoo) -> MyFoo
myfoo = foo
$ runhaskell test.hs
test.hs:9:8:
Couldn't match expected type `MyFoo' against inferred type `Foo'
In the expression: foo
In the definition of `myfoo': myfoo = foo
Greetings,
JOachim
--
Joachim Breitner
e-Mail: mail at joachim-breitner.de
Homepage: http://www.joachim-breitner.de
ICQ#: 74513189
Jabber-ID: nomeata at joachim-breitner.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091203/e4d5ce04/attachment-0001.bin
More information about the Haskell-Cafe
mailing list