{-|
Module      : Palindrome
Description : Palindrome checker
Copyright   : (c) 2025 Mirko Westermeier
License     : MIT

Comprehensive palindrome detection library.
-}
module Palindrome where

-- |  Checks whether a given list of comparable things is a palindrome
--    (is the same after reversing the structure).
--
-- >>> isPalindrome "racecar"
-- True
--
-- >>> isPalindrome "()()"
-- False
--
-- >>> isPalindrome [1,2,3,2,1]
-- True
--
-- >>> isPalindrome []
-- True
--
-- >>> isPalindrome "a"
-- True
isPalindrome :: Eq a => [a] -> Bool
isPalindrome :: forall a. Eq a => [a] -> Bool
isPalindrome []     = Bool
True
isPalindrome [a
_]    = Bool
True
isPalindrome (a
x:[a]
xs) = a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== [a] -> a
forall a. HasCallStack => [a] -> a
last [a]
xs Bool -> Bool -> Bool
&& [a] -> Bool
forall a. Eq a => [a] -> Bool
isPalindrome ([a] -> [a]
forall a. HasCallStack => [a] -> [a]
init [a]
xs)