the
is defined as follows:
the :: Eq a => [a] -> a
the (x:xs)
| all (x ==) xs = x
| otherwise = error "GHC.Exts.the: non-identical elements"
the [] = error "GHC.Exts.the: empty list"
Based on this we can directly deduce theMay
:
theMay :: Eq a => [a] -> Maybe a
theMay (x:xs)
| all (x ==) xs = Just x
| otherwise = Nothing
theMay [] = Nothing