19 lines
352 B
Haskell
19 lines
352 B
Haskell
{-|
|
|
Module : Misc
|
|
Description : Contains miscelaneous helper functions which do not fit elsewhere
|
|
-}
|
|
|
|
module Misc where
|
|
|
|
infixl 3 !?
|
|
-- | Safe version of (!!)
|
|
(!?) :: [a] -> Int -> Maybe a
|
|
[] !? i = Nothing
|
|
(x:xs) !? 0 = Just x
|
|
(x:xs) !? n = xs !? (n-1)
|
|
|
|
infixl 0 $>
|
|
-- | Backwards function application
|
|
($>) :: a -> (a -> b) -> b
|
|
x $> f = f x
|