module Chiasma.Data.List(
  head',
  tail',
  last',
) where

head' :: [a] -> Maybe a
head' :: [a] -> Maybe a
head' (a
a : [a]
_) = a -> Maybe a
forall a. a -> Maybe a
Just a
a
head' [a]
_ = Maybe a
forall a. Maybe a
Nothing

tail' :: [a] -> Maybe [a]
tail' :: [a] -> Maybe [a]
tail' (a
_ : [a]
as) = [a] -> Maybe [a]
forall a. a -> Maybe a
Just [a]
as
tail' [a]
_ = Maybe [a]
forall a. Maybe a
Nothing

last' :: [a] -> Maybe a
last' :: [a] -> Maybe a
last' = [a] -> Maybe a
forall a. [a] -> Maybe a
head' ([a] -> Maybe a) -> ([a] -> [a]) -> [a] -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
reverse