From 77983153f9e891f1199c8faa16dcb2a0e8bcbbb9 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Wed, 7 May 2014 04:49:30 +0200 Subject: make the check for overflow cleaner Ignore-this: c12448f9219c8a29f2707526691acfda darcs-hash:20140507024930-1499c-52860fb59794c3f370f27158b0936f845fce6ded.gz --- tests/Utils.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/Utils.hs') diff --git a/tests/Utils.hs b/tests/Utils.hs index 2d9df81..e3eef0f 100644 --- a/tests/Utils.hs +++ b/tests/Utils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE RankNTypes #-} module Utils where import XMonad.StackSet hiding (filter) @@ -35,5 +36,12 @@ applyN Nothing f v = v applyN (Just 0) f v = v applyN (Just n) f v = applyN (Just $ n-1) f (f v) - tags x = map tag $ workspaces x + + +-- | noOverflows op a b is True if @a `op` fromIntegral b@ overflows (or +-- otherwise gives the same answer when done using Integer +noOverflows :: (Integral b, Integral c) => + (forall a. Integral a => a -> a -> a) -> b -> c -> Bool +noOverflows op a b = toInteger (a `op` fromIntegral b) == toInteger a `op` toInteger b + -- cgit v1.2.3