[Haskell-cafe] Type families not as useful over functions

Jonathan Cast jonathanccast at fastmail.fm
Thu Feb 12 19:40:49 EST 2009

On Fri, 2009-02-13 at 11:15 +1100, John Ky wrote:
> Hi Johnaton,
> Ah yes.  That makes sense.  Is there a way to define type r to be all
> types except functions?

Not without overlapping instances.  I *think* if you turn on {-#
LANGUAGE OverlappingInstances #-} then

  instance Broadcast r where
    type Result = [r]
    broadcast xn = xn

should do what you want (instance resolution delayed until r has a type
constructor at top level; this instance selected if no other instance is
in scope --- should be equivalent to r not a function type unless
someone else defines an instance!); but I know that's not a pretty way
of doing things.


More information about the Haskell-Cafe mailing list