[Haskell-cafe] Are there arithmetic composition of functions?
nominolo at googlemail.com
Tue Mar 20 03:49:00 CET 2012
I don't understand this discussion. He explicitly said "If you are
willing to depend on a recent version of base". More precisely, he
meant GHC 7.4 which includes the latest version of base. Yes, this is
incompatible with the Haskell2010 standard, but it did go through the
library submission process (unless I'm mistaken).
It is also easy to add nonsense instances for functions to make this
work with the Haskell2010 definition of the Num class.
instance Eq (a -> b) where
f == g = error "Cannot compare two functions (undecidable for
instance Show (a -> b) where show _ = "<function>"
Yes, these instances are not very useful, but they let you get around
this unnecessary restriction of the Num class. (I expect this to be
fixed in future versions of the Haskell standard.)
On 20 March 2012 02:37, Richard O'Keefe <ok at cs.otago.ac.nz> wrote:
> On 20/03/2012, at 2:27 PM, Jerzy Karczmarczuk wrote:
>> Richard O'Keefe:
>>> class (Eq a, Show a) => Num a
>>> where (+) (-) (*) negate abs signum fromInteger
>>> where functions are for good reason not members of Eq or Show.
>> This is an old song, changed several times. I have no intention to discuss, but please, Richard O'Keefe:
>> WHICH GOOD REASONS??
> It is still there in the Haskell 2010 report.
> The UHC user manual at
> lists differences between UHC and both Haskell 98 and
> Haskell 2010, but is completely silent about any change to
> the interface of class Num, and in fact compiling a test
> program that does 'instance Num Foo' where Foo is *not* an
> instance of Eq or Show gives me this response:
> [1/1] Compiling Haskell mynum (mynum.hs)
> EH analyses: Type checking
> Predicates remain unproven:
> preds: UHC.Base.Eq mynum.Foo:
> This is with ehc-1.1.3, Revision 2422:2426M,
> the latest binary release, downloaded and installed today.
> The release date was the 31st of January this year.
> GHC 7.0.3 doesn't like it either. I know ghc 7.4.1 is
> out, but I use the Haskell Platform, and the currently
> shipping version says plainly at
> that it provides GHC 7.0.4.
> You may have no intention of discussing the issue,
> but it seems to *me* that "this will not work in 2012
> Haskell compiler mostly conforming to Haskell 2010
> because Haskell 2010 says it shouldn't work" is a pretty
> sound position to take.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Push the envelope. Watch it bend.
More information about the Haskell-Cafe