aboutsummaryrefslogtreecommitdiff
path: root/Utils.hs
blob: 1d34a5c1c5bd5631565637e65ba8abf089f2f1c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Utils where

import Data.List
import Data.Maybe


uniq :: Eq a => [a] -> [a]
uniq (a:b:cs) | a == b = uniq (b:cs)
              | otherwise = a : uniq (b:cs)
uniq l = l

contains :: Eq a => [a] -> a -> Bool
contains l v = isJust $ find (== v) l

roundUp :: Integral a => a -> a -> a
roundUp n sz = (n + sz - 1) `div` sz * sz

assertM :: Monad m => Bool -> m ()
assertM True = return ()
assertM False = error "assertM failed"