diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-29 19:03:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-29 19:03:35 +0530 |
| commit | fc2a09facce2fe6d06769712ea992f99bf15c8e2 (patch) | |
| tree | d58a5b11207b88ca79d62a92bf47d8781d20d4e1 /src/Chelleport/Utils.hs | |
| parent | c1e05401d5c3cf90440e62a3423d2b52cfc46999 (diff) | |
| download | chelleport-fc2a09facce2fe6d06769712ea992f99bf15c8e2.tar.gz chelleport-fc2a09facce2fe6d06769712ea992f99bf15c8e2.zip | |
Make backspace delete a single character in search + split up key input action
Diffstat (limited to 'src/Chelleport/Utils.hs')
| -rw-r--r-- | src/Chelleport/Utils.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Chelleport/Utils.hs b/src/Chelleport/Utils.hs index 3f0dd73..4367c4f 100644 --- a/src/Chelleport/Utils.hs +++ b/src/Chelleport/Utils.hs @@ -37,15 +37,21 @@ benchmark msg m = do pure result itemAt :: [a] -> Int -> Maybe a -itemAt [] _ = Nothing itemAt (x : _) 0 = Just x itemAt (_ : xs) i = itemAt xs (i - 1) +itemAt _ _ = Nothing clamp :: (Integral a) => (a, a) -> a -> a clamp (low, high) n = max low (min high n) -(<&&>) :: [a -> Bool] -> a -> Bool -(<&&>) preds ev = all (\p -> p ev) preds +cycleInRange :: (Integral a) => (a, a) -> a -> a +cycleInRange (low, high) n + | n < low = high + | high <= low = low + | otherwise = low + ((n - low) `mod` (high - low + 1)) + +(<&&>) :: (a -> Bool) -> (a -> Bool) -> a -> Bool +(<&&>) p1 p2 x = p1 x && p2 x (<||>) :: (a -> Bool) -> (a -> Bool) -> a -> Bool (<||>) p1 p2 x = p1 x || p2 x |
