----------------------------------------------------------------------------- -- -- Module : Utils -- Copyright : -- License : AllRightsReserved -- -- Maintainer : -- Stability : -- Portability : -- -- | -- ----------------------------------------------------------------------------- module Utils where import Data.Maybe import Data.Char -- | this function will return just a if it can cast it to an a. maybeRead :: Read a => String -> Maybe a maybeRead = fmap fst . listToMaybe . reads -- | Replaces all instances of a value in a list by another value. replace :: Eq a => a -- ^ Value to search -> a -- ^ Value to replace it with -> [a] -- ^ Input list -> [a] -- ^ Output list replace x y = map (\z -> if z == x then y else z) yes = ["o", "oui", "y", "yes", "v", "vrai", "true"] toLowerS = map toLower isYes a = toLowerS a `elem` yes