[Haskell-cafe] Value classes

Mads Lindstrøm mads_lindstroem at yahoo.dk
Wed Dec 30 15:12:55 EST 2009


Hi

A function inc5

  inc5 :: Float -> Float
  inc5 x = x + 5

can only be a member of a type class A, if we make all functions from
Float -> Float members of type class A. Thus, I assume, that _type_
class is named type class, as membership is decided by types.

However, it makes no sense to say that all functions from Float -> Float
are invertible or continuous. We would want to specifically say that
inc5 is continuous, not all Float -> Float functions. Thus, we could
have another abstraction, lets call it _value_ class, where we could say
that an individual value (function) could be member. We could say
something like:

  class Invertible (f :: a -> a) where
    invert :: f -> (a -> a)

  instance Invertible inc5 where
    invert _ = \x -> x - 5

In many cases this would be too specific. We would like to say, that
applying the first argument to `+` returns an invertible function.
Something like:

  instance Invertible (`+` x) where
    invert (x +) = \y -> y - x

We would properly also like to say, that composing two invertible
functions results in another invertible function. I guess there are many
more examples.

This idea, of value classes, do not feel all that novel. Somebody has
properly thought about it before, but gave it a different name. If
anybody has links to some papers it would be much appreciated. If
anybody has some thoughts of the desirability of value class it would
also be much appreciated.


/Mads Lindstrøm



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091230/7f7418cf/attachment.bin


More information about the Haskell-Cafe mailing list