I wan't to know why Haskell doesn't like pooint-free style. For example, 0) and 1) are Unresolved top-level overloading, but 2) is accepted by the type system. 0) show' = show 1) show' = (\x->show x) 2) show x = show x What are the differences between 0), 1) and 2) ? They must have the same type. Point-free style is consice and more functional, so I like it. I think quite many of functional programmers would prefer. It is especially annoying when using compoisitoins to define new function. I should write like this in order to pass the type system f x y = (g . h . k) x y instead of writing just compositions like below. f = g . h . k
On Mon, 05 May 2003 13:11:49 +0900 Ahn Ki-yung <kyagrd@bawi.org> wrote:
I wan't to know why Haskell doesn't like pooint-free style.
For example, 0) and 1) are Unresolved top-level overloading, but 2) is accepted by the type system.
0) show' = show 1) show' = (\x->show x) 2) show x = show x
What are the differences between 0), 1) and 2) ? They must have the same type.
And 0 and 1 must have a monomorphic type. This is the monomorphism restriction that is a fact of life with Haskell. You don't have to completely eta expand (as in the cut other example). As an alternative to eta expansion you can simply provide the type. Finally, there is a GHC option (and probably something similar for others) that will remove the monomorphism restriction, but I imagine it may cause problems.
Ahn Ki-yung wrote:
I wan't to know why Haskell doesn't like pooint-free style.
For example, 0) and 1) are Unresolved top-level overloading, but 2) is accepted by the type system.
0) show' = show 1) show' = (\x->show x) 2) show x = show x
What are the differences between 0), 1) and 2) ? They must have the same type.
This is due to the monomorphism restriction; see: http://www.haskell.org/onlinereport/decls.html#sect4.5.5 -- Glynn Clements <glynn.clements@virgin.net>
G'day all. On Mon, May 05, 2003 at 01:11:49PM +0900, Ahn Ki-yung wrote:
For example, 0) and 1) are Unresolved top-level overloading, but 2) is accepted by the type system.
As others have pointed out, you have been bitten by the monomorphism restriction. In your case, all of the versions of your code will work just fine if you put in an explicit type declaration (which is good programming practice anyway). Cheers, Andrew Bromage
participants (4)
-
Ahn Ki-yung -
Andrew J Bromage -
Derek Elkins -
Glynn Clements