FD use cases (was Re: postponing discussion on exceptions and deepSeq)

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Apr 12 17:21:06 EDT 2006

isaac jones <ijones at galois.com> wrote:

> Ross has asked for use cases for functional dependencies and so far
> has only two replies.  Surely there are those on this list who have
> use of functional dependencies?

Personally, I have never used FDs, but I recall some discussion we had
in the Hat tracing project about the possibility of using them to solve
a problem we had.  (In the end, I think we decided it was either too
complex, or the particular FD use case was not supported by any

The idea was to drop from traced computations down to the original
computations (unwrap), and lift them back up again (wrap), in order to
run "trusted" code at the original speed.  This class looks something

   class Wrap a b | a -> b, b -> a where
      wrap   :: a -> R b
      unwrap :: R b -> a

Nothing too unusual I'm sure.  But there are some subtleties to do with
the way this class interacts with other classes.  A sketch of these is
given in a short memo, attached to the wiki under "Use Cases" at


The relevant section is 3.2.  One interesting thing to note for the FD
discussion is the need/possibility of defining the same multi-parameter
class at several different kinds.


More information about the Haskell-prime mailing list