2021-09-17 17:36:58 +02:00
|
|
|
{-|
|
|
|
|
Module : Misc
|
|
|
|
Description : Contains miscelaneous helper functions which do not fit elsewhere
|
|
|
|
-}
|
|
|
|
|
2021-09-14 17:06:34 +02:00
|
|
|
module Misc where
|
|
|
|
|
2021-09-14 18:24:05 +02:00
|
|
|
infixl 3 !?
|
2021-09-17 17:36:58 +02:00
|
|
|
-- | Safe version of (!!)
|
2021-09-14 17:06:34 +02:00
|
|
|
(!?) :: [a] -> Int -> Maybe a
|
|
|
|
[] !? i = Nothing
|
|
|
|
(x:xs) !? 0 = Just x
|
|
|
|
(x:xs) !? n = xs !? (n-1)
|
2021-09-20 13:21:48 +02:00
|
|
|
|
|
|
|
infixl 0 $>
|
|
|
|
-- | Backwards function application
|
|
|
|
($>) :: a -> (a -> b) -> b
|
|
|
|
x $> f = f x
|