
Hi Daniel,
A more functional approach might be:
type Substitution = String -> Maybe Value
single :: String -> Value -> Substitution
table :: Table -> Substitution
substitute :: Substitution -> Tree -> Tree
For better performance and a lot more features, you could switch to
type Substitution = Data.Map String Value
- Conal
On Fri, Feb 13, 2009 at 2:40 AM, Daniel Kraft
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
In the case I believe it would certainly be good to be able to name both functions the same, but I fear I can not do so? There are languages where this is explicitelly allowed (e.g. C++ or Java), so I don't think it is such an unuseful or evil thing.
Daniel
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe