Safe Haskell | None |
---|---|
Language | Haskell2010 |
Unsafe utilities.
This module should be imported qualified.
Synopsis
- module Universum.Unsafe
- fromIntegral :: (HasCallStack, Integral a, Integral b) => a -> b
- fromInteger :: (HasCallStack, Integral a) => Integer -> a
- unsafe :: (HasCallStack, Buildable a) => Either a b -> b
- unsafeM :: (MonadFail m, Buildable a) => Either a b -> m b
Documentation
module Universum.Unsafe
Unsafe converters between Integral
types checking for overflow/underflow
fromIntegral :: (HasCallStack, Integral a, Integral b) => a -> b Source #
Unsafe converter between Integral
types
checking for overflow/underflow. Return
value
if conversion does not produce
overflow/underflow and raise an exception
with corresponding error message otherwise.
It is needed to replace fromIntegral
which misses most of the overflow/underflow checks.
Note the function is strict in its argument.
fromInteger :: (HasCallStack, Integral a) => Integer -> a Source #
Unsafe converters from Either
for making unsafe counter-parts of safe functions
unsafe :: (HasCallStack, Buildable a) => Either a b -> b Source #
Unsafe converter from Either
, which uses buildable
Left
to throw an exception with error
.
It is primarily needed for making unsafe counter-parts
of safe functions. In particular, for replacing
unsafeFName x = either (error . pretty) id
constructors and converters, which produce many similar
functions at the call site, with unsafe . fName $ x
.