List types
Scott Turner
p.turner@computer.org
Mon, 13 Nov 2000 04:13:07 -0500
You could make a type like this:
data C a b = Raw b | Cooked ( a -> C a b )
ap :: C a b -> a -> C a b
ap (Cooked f) v = f v
cook :: C a (a -> t) -> C a t
cook (Cooked f) = Cooked g
where
g a = cook (f a)
cook (Raw f) = Cooked g
where
g a = Raw (f a)
foo x y z = x <= y && y <= z
f3 = cook $ cook $ cook $ Raw foo
test = f3 `ap` 1 `ap` 2 `ap` 3
Though you could do something similar with a list-based approach.
-- Scott
At 20:12 2000-11-12 -0800, you wrote:
>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]
>
>I want to be able to curry the a's one at a time.
--
Scott Turner
p.turner@computer.org http://www.ma.ultranet.com/~pkturner