[Haskell-cafe] Defining show for a function type.
Fritz Ruehr
fruehr at willamette.edu
Mon Jul 10 23:55:13 EDT 2006
On Jul 10, 2006, at 8:44 AM, Johan Grönqvist wrote:
> "deriving Show" is impossible as Func is not instance of Show. Can I
> make it instance of Show? I just want to define something like
> ...
> and I am not interested in actually displaying any information about
> the function, ...
Were you interested in "seeing" the function, you could do so, at least
for finite, total functions (you can also enumerate them, compare them
for equality, etc.). See my haskell-cafe message at
<http://www.haskell.org/pipermail/haskell-cafe/2006-April/015197.html>.
By way of example, and quoting a sample interaction from that message:
> > not == not
> True
> > not == id
> False
> > id == (not . not)
> True
> > fromEnum not
> 1
> > not == toEnum 1
> True
> > not
> (\x -> case x of False -> True; True -> False)
> > not == (\x -> case x of False -> True; True -> False)
> True
> > id :: Bool -> Bool
> (\x -> case x of False -> False; True -> True)
> > const True :: Bool -> Bool
> (\x -> case x of False -> True; True -> True)
-- Fritz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1100 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060710/4f3c320f/attachment.bin
More information about the Haskell-Cafe
mailing list