module RESTng.Utils where import Data.Char(toLower) -- map-like functions mapFst f (x,y) = (f x, y) mapSnd f (x,y) = (x, f y) -- string conversion low = map toLower -- n tuples fst3 (x,_,_) = x snd3 (_,x,_) = x trd3 (_,_,x) = x fst4 (x,_,_,_) = x snd4 (_,x,_,_) = x trd4 (_,_,x,_) = x fourth4 (_,_,_,x) = x -- list processing lookupByFun :: Eq a => (b->a) -> a -> [b] -> Maybe b lookupByFun f a [] = Nothing lookupByFun f a (b:bs) = if (f b == a) then Just b else lookupByFun f a bs safeHead :: [a] -> Maybe a safeHead [] = Nothing safeHead (x:_) = Just x