A quadratic version for a simplistic cost function (Waterman) (sequence alignment)
This is Waterman's reformulation of the Needleman-Wunsch algorithm for a simple additive gap function, running in O(n^2). Read the full description in Systematic Dynamic Programming in Bioinformatics.
```> module Waterman where

> import Array
> import List
> import TTCombinators
```
The signature:
```> data Alignment = Nil                   |
>                  D  Char Alignment     |
>                  I  Alignment Char     |
>                  R  Char Alignment Char
>                                        deriving (Eq, Show)
```
The yield grammar:
```> waterman_alignments alg inpX inpY = axiom alignment where
>   (nil, d, i, r, h)    = alg
>
>   alignment  = tabulated (
>                 nil ><< empty                         |||
>                 r   <<< xbase -~~ alignment ~~- ybase |||
>                 d   <<< xbase -~~ alignment           |||
>                 i   <<<           alignment ~~- ybase ... h)
```
Bind input:
```>   infixl 7  -~~, ~~-
>   (_, _, xbase, ybase, empty, _, _, (-~~), (~~-), tabulated)
>     = bindParserCombinators inpX inpY
```
Enumeration algebra:
```> enum :: Waterman_Algebra Char Alignment
> enum = (nil, d, i, r, h) where
>    nil = Nil
>    d   = D
>    i   = I
>    r   = R
>    h   = id
```
Pretty printing algebra:
```> prettyprint :: Waterman_Algebra Char (String, String)
> prettyprint = (nil, d, i, r, h) where
>   nil         = ("","")
>   d x (l,r)   = (x:l, gap:r)
>   i (l,r) x   = (gap:l, x:r)
>   r x (l,r) y = (x:l,y:r)
>   h           = id
>   gap         = '-'
```
Counting Algebra:
```> count :: Waterman_Algebra Char Int
> count = (nil, d, i, r, h) where
>   nil     = 1
>   d x s   = s
>   i s x   = s
>   r a s b = s
>   h []    = []
>   h xs    = [sum xs]
```
The scoring algebras:
```> wgap :: Waterman_Algebra Char Int
> wgap = (nil, d, i, r, h) where
>   nil     = 0
>   d x s   = s + gap x
>   i s y   = s + gap y
>   r a s b = s + w a b
>   h []    = []
>   h xs    = [maximum xs]
>  -- simple definitions for gap and w:
>   gap x = (-1)
>   w a b = if a==b then 1 else (-1)

> unit :: Waterman_Algebra Char Int
> unit = (nil, d, i, r, h) where
>   nil     = 0
>   d x s   = s - 1
>   i s y   = s - 1
>   r a s b = if a==b then s+1 else s-1
>   h []    = []
>   h xs    = [maximum xs]
```
Algebra type:
```> type Waterman_Algebra alphabet answer = (
>   )
```
Algebra cross product:
```> infix ***
> (***) :: Eq answer1 =>