An implementation for sequences in Haskell.

module Sequences (
Seq ,
Deque ,
ap2Prep )

where

data Seq a = NIL | Cons a ( Seq a )
deriving (Eq , Read , Show)

( < |) : : ( Eq a) => a −> Seq a −> Seq a
infixr 9 <|
( < |) x y = Cons x y
( | >) : : ( Eq a) => Seq a −> a −> Seq a
infixr 9 |>
( | >) NIL x = x < | NIL
( | >) ( Cons a x ) b = a < | ( x | > b)

data Deque a = Bot | Prep a ( Deque a ) | Ap ( Deque a ) a
deriving (Eq , Read , Show)
ap2Prep : : Deque a −> Deque a
ap2Prep Bot = Bot
ap2Prep ( Prep a x ) = ( Prep a ( ap2Prep x ) )
ap2Prep (Ap Bot a ) = Prep a Bot
ap2Prep (Ap ( Prep a x ) b ) = Prep a ( ap2Prep (Ap x b ) )
ap2Prep (Ap (Ap x a ) b ) = ap2Prep (Ap ( ap2Prep (Ap x a ) ) b)