Catalog of computation strategies

when something may or may not return a value
use Maybe

when something may return 0,1 or more values
Submitted by lightstep on Wed, 04/26/2006 - 10:26am.

A general type constructor for trees would need to get the amounts for the children of each node:
Tree :: * -> [Integer] -> *
type TwoThreeTree a = Tree a [0,2,3]

However, in haskell we don't have dependent types, so we need to pass a general type-function to Tree, with kind (* -> *), that would construct the type for all the children of a node from the type of one node:
Tree :: * -> (* -> *) -> *
data Tree a mult = Tree (a, mult (Tree a mult))
data TwoThreeMult a = Nil | Two (a, a) | Three (a, a, a)
type TwoThreeTree a = Tree a TwoThreeMult

Submitted by lightstep on Wed, 04/26/2006 - 10:28am.

I forgot to add that the `mult' parameter of `Tree' will always be a functor. This will enable generic traversal operations for trees.

Comment viewing options
