On Fri, 2009-02-13 at 11:40 +0100, Daniel Kraft wrote: > Colin Adams wrote: > > If you have two functions that do two different things, then they > > certainly OUGHT to have different names. > > Well, they do "the same thing" but for different arguments; it's like this: > > Table is a table of name-value pairs I want to substitute in a tree-like > structure using: > > substitute :: Table -> Tree -> Tree > > For substituting a single name-value pair I want to define this utitlity > routine so I don't have to construct a Table all the time in the user code: > > substitute :: String -> Value -> Tree -> Tree
You can write it like this: class Substitutable a where substitute :: a -> Tree -> Tree instance Substitutable Table where ... instance Substitutable (String, Value) where ...
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe