[Haskell-cafe] Re: instance Eq (a -> b)
Maciej Piechotka
uzytkownik2 at gmail.com
Thu Apr 15 01:40:28 EDT 2010
On Wed, 2010-04-14 at 12:16 -0700, Ashley Yakeley wrote:
> On 2010-04-14 11:12, John Meacham wrote:
> > On Wed, Apr 14, 2010 at 02:07:52AM -0700, Ashley Yakeley wrote:
> >>> So the facts that
> >>> (1) f == g
> >>> (2) f undefined = 6
> >>> (3) g undefined = undefined
> >>> is not a problem?
> >>
> >> This is not a problem. f and g represent the same moral function,
> they
> >> are just implemented differently. f is smart enough to know that
> its
> >> argument doesn't matter, so it doesn't need to evaluate it. g waits
> >> forever trying to evaluate its function, not knowing it doesn't
> need it.
> >
> > Hence they are distinct functions,
>
> They are distinct Haskell functions, but they represent the same
> moral
> function.
>
Are
f 0 = 1
f n = f (n - 1) + f (n - 2)
and
g 0 = 1
g n | n > 0 = g (n - 1) + g (n - 2)
| n < 0 = g (n + 2) - g (n + 1)
The same (morally) function?
Are:
f x = 2*x
and
f x = undefined
The same function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100415/aceda99e/attachment.bin
More information about the Haskell-Cafe
mailing list