[Haskell-cafe] Simplifying a IsFunction type class using type equality constraints

Ryan Ingram ryani.spam at gmail.com
Mon Oct 6 05:53:46 EDT 2008

On Sat, Oct 4, 2008 at 2:58 AM, Corey O'Connor <coreyoconnor at gmail.com> wrote:
> I recently had a need to use the IsFunction typeclass described by Oleg here:
> http://okmij.org/ftp/Haskell/isFunction.lhs
> and am wondering if the use of the TypeCast class can be correctly
> replaced by a type equality constraint.

I noticed this as well; it seemed to work in my tests, although I
haven't seen any proof that they are equivalent.  The HList paper
mentions that the behavior of TypeCast is directly related to type
equality coercions in System F(C), GHC's core language.  So it's not
that surprising that it can be replaced with a type-equality
constraint, which is a more direct way of introducing the same
core-language code.

If you want to know for sure, you can look at the output of ghc
-ddump-simpl on each program.

  -- ryan

More information about the Haskell-Cafe mailing list