{-# LANGUAGE BangPatterns #-}
module XMonad.Prelude (
module Exports,
fi,
chunksOf,
(.:),
(!?),
) where
import Control.Applicative as Exports
import Control.Monad as Exports
import Data.Bool as Exports
import Data.Char as Exports
import Data.Foldable as Exports
import Data.Function as Exports
import Data.Functor as Exports
import Data.List as Exports
import Data.Maybe as Exports
import Data.Monoid as Exports
import Data.Traversable as Exports
fi :: (Integral a, Num b) => a -> b
fi :: a -> b
fi = a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral
chunksOf :: Int -> [a] -> [[a]]
chunksOf :: Int -> [a] -> [[a]]
chunksOf Int
_ [] = []
chunksOf Int
i [a]
xs = [a]
chunk [a] -> [[a]] -> [[a]]
forall a. a -> [a] -> [a]
: Int -> [a] -> [[a]]
forall a. Int -> [a] -> [[a]]
chunksOf Int
i [a]
rest
where !([a]
chunk, [a]
rest) = Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
i [a]
xs
(!?) :: [a] -> Int -> Maybe a
!? :: [a] -> Int -> Maybe a
(!?) [a]
xs Int
n | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = Maybe a
forall a. Maybe a
Nothing
| Bool
otherwise = [a] -> Maybe a
forall a. [a] -> Maybe a
listToMaybe ([a] -> Maybe a) -> [a] -> Maybe a
forall a b. (a -> b) -> a -> b
$ Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
n [a]
xs
(.:) :: (a -> b) -> (c -> d -> a) -> c -> d -> b
.: :: (a -> b) -> (c -> d -> a) -> c -> d -> b
(.:) = ((d -> a) -> d -> b) -> (c -> d -> a) -> c -> d -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (((d -> a) -> d -> b) -> (c -> d -> a) -> c -> d -> b)
-> ((a -> b) -> (d -> a) -> d -> b)
-> (a -> b)
-> (c -> d -> a)
-> c
-> d
-> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> (d -> a) -> d -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.)