haskell - What would the type of a list of cascading functions be? -


In the Haskell syntax, we type as a (abstract) type of [a -> gt; B] , which is a list for A's works, it will have a solid type of [int -> gt; Int] , such as map (*) [1..10] . What [a - & gt; Is it possible to list a type of cascading functions? B, B - & gt; C, C - & gt; D, ...] ? The individual elements of the list are all different (I think) so I do not think it is possible. But is it possible with dependent types? What will be the signature of this type (preferably in pseudo-hoccale syntax)?

You can not do this with a plain list, but you can type your own list-like type Can create:

  {- # LANGUAGE GADTs # -} Data cascading list io where id :: Cascading list Ii Cascade :: (b -> o) - & gt; Cascading List I B - & gt; You can create these  CascadingList  s as follows: 

  addOnePositive :: CascadingList Int Bool addOnePositive = Cascade () & Gt; 0) $ Cascade (+1) $ Id  

You can 'summarize' lists:

  collapse :: cascading list ab - & gt; ; A - & gt; B fall id = id fall (waterfall fc) = f. Fall c  

Then you

  collapse addOnePositive 0 == true  

note that it does not take Keeping in mind the types of intermediate tasks, it can not be what you want.


I just realized that this is an easy change to make some [c -> d, b -> c, a -> b] close to your intentions; I can edit it but I think you get this idea.


Comments