| Copyright | (c) roki 2019 |
|---|---|
| License | MIT |
| Maintainer | falgon53@yahoo.co.jp |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Htcc.Utils
Description
General-purpose utilities
Synopsis
- module Htcc.Utils.List
- bothM :: Monad m => (a -> m b) -> (a, a) -> m (b, b)
- (*^*) :: Monad m => (a -> m c) -> (b -> m d) -> (a, b) -> m (c, d)
- maybe' :: b -> Maybe a -> (a -> b) -> b
- isStrictSpace :: Char -> Bool
- module Htcc.Utils.Text
- toNatural :: Integral i => i -> Natural
- toInteger :: Natural -> Integer
- module Htcc.Utils.Print
- module Htcc.Utils.Tuple
- module Htcc.Utils.Bool
- module Htcc.Utils.NaturalTransformations
- toInts :: Integral i => i -> [Int]
Extra functions for lists
module Htcc.Utils.List
For Monad
bothM :: Monad m => (a -> m b) -> (a, a) -> m (b, b) Source #
The monadic both.
e.g.:
>>>a <- newIORef (42 :: Int)>>>b <- newIORef (53 :: Int)>>>bothM readIORef (a, b) >>= print(42,53)
(*^*) :: Monad m => (a -> m c) -> (b -> m d) -> (a, b) -> m (c, d) infixr 3 Source #
The monadic ***.
e.g.:
>>>a <- newIORef 1>>>b <- newIORef 2>>>(writeIORef a *^* writeIORef b) (42, 53) >> bothM readIORef (a, b) >>= print(42,53)
For Data.Maybe
For Char
isStrictSpace :: Char -> Bool Source #
isStrictSpace returns True only if the given string is not a linefeed code and isSpace returns True, otherwise returns False.
For Data.Text
module Htcc.Utils.Text
For Numeric.Natural
toNatural :: Integral i => i -> Natural Source #
toNatural is a shortcut for fromIntegral :: Integral i => i -> Natural
toInteger :: Natural -> Integer Source #
toInteger is a shortcut for fromIntegral :: Natural -> Integer
For print shortcuts
module Htcc.Utils.Print
For triples and quadruple
module Htcc.Utils.Tuple
Boolean methods
module Htcc.Utils.Bool
Natural transformations
For data type
toInts :: Integral i => i -> [Int] Source #
Convert the instance of Integral to Int. When it cause overflow, express it as a list of Ints divided into multiple values.
toInts is useful for functions that have an Int type as an argument. e.g.:
>>>toInts (fromIntegral (maxBound :: Int) + 1 :: Integer)[9223372036854775807,1]>>>toInts (fromIntegral (maxBound :: Int) * 3 + 4 :: Integer)[9223372036854775807,9223372036854775807,9223372036854775807,4]