pubsub-0.10: Utils/Data/List.hs
--------------------------------------------------------------------
-- |
-- Module : Utils.Data.List
-- Copyright : (c) Sigbjorn Finne, 2009
-- License : BSD3
--
-- Maintainer: Sigbjorn Finne <sof@forkIO.com>
-- Stability : provisional
-- Portability:
--
--------------------------------------------------------------------
module Utils.Data.List
( matchPrefix -- :: Eq a => [a] -> [a] -> Maybe [a]
, transElem -- :: Eq a => a -> a -> a -> a
) where
matchPrefix :: Eq a => [a] -> [a] -> Maybe [a]
matchPrefix [] xs = Just xs
matchPrefix (x:xs) (y:ys)
| x == y = matchPrefix xs ys
| otherwise = Nothing
transElem :: Eq a => a -> a -> a -> a
transElem t f x
| t == x = f
| otherwise = x