List types

Richard ru@ohio.river.org
Sun, 12 Nov 2000 22:49:35 -0800 (PST)


Eric Allen Wohlstadter writes:
>I would like to be able to make a list that contains functions which take
>arguments of a certain type 'a'. However I don't know how many 'a'
>arguments there are. For example I'd like to be able to make a list of
>f,g, and h.
>
>f::a->b
>g::a->a->b
>h::a->a->a->b
>[f,g,h]
>
>My solution so far is declare a type Element like this:
>data Element a b c d = One a | Two b | Three c | Four d
>and then I can make my list like this,
>[One f,Two g,Three h]

Don't you mean this?

data Element a b=One (a->b)
                |Two (a->a->b)
                |Three (a->a->b)

>This gets very ugly. Do you guys have any ideas?

I wish you would supply more context, so I could see where the ugliness
comes in.  Hard to fix a problem you cannot see.