I have to construct a Snoc list, the reverse of Cons. I’ve done to add one element forward i don’t know how to concatenate two lists. That’s the situation now:
module Tsil where
data Tsil a = Lin
| Snoc (Tsil a, a)
deriving (Eq, Ord, Show, Read)
empty :: Tsil a
empty = Lin
infixr 2 |:
(|:) :: a -> Tsil a -> Tsil a
(|:) a t = Snoc (t, a)
infixr 5 |++
(|++) :: Tsil a -> Tsil a -> Tsil a
(|++) a Lin = a
(|++) Lin a = a
Your list type is the same as Haskell’s, so just make it a Haskell list, concatenate, convert back. Hooray for reusability in Haskell 😉