htcc-0.0.0.1: The full scratch implementation of tiny C compiler (x86_64)
Copyright(c) roki 2019
LicenseMIT
Maintainerfalgon53@yahoo.co.jp
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Htcc.Utils

Description

General-purpose utilities

Synopsis

Extra functions for lists

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

maybe' :: b -> Maybe a -> (a -> b) -> b Source #

maybe` is maybe with changed argument order.

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

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

For triples and quadruple

Boolean methods

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]