witch-0.3.4.0: Convert values from one type into another.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Witch.TryFrom

Synopsis

Documentation

class TryFrom source target where Source #

This type class is for converting values from some source type into some other target type. The constraint TryFrom source target means that you may be able to convert from a value of type source into a value of type target, but that conversion may fail at runtime.

This type class is for conversions that can sometimes fail. If your conversion always succeeds, consider implementing From instead.

Methods

tryFrom :: source -> Either (TryFromException source target) target Source #

This method implements the conversion of a value between types. At call sites you may want to use tryInto instead.

-- Avoid this:
tryFrom (x :: s)

-- Prefer this:
tryFrom @s

Consider using maybeTryFrom or eitherTryFrom to implement this method.

Instances

Instances details
TryFrom Double Int Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Int8 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Int16 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Int32 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Int64 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Integer Source #

Converts via Rational when the input is between -9,007,199,254,740,991 and 9,007,199,254,740,991 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Double Natural Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Rational Source #

Uses toRational when the input is not NaN or infinity.

Instance details

Defined in Witch.Instances

TryFrom Double Word Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Word8 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Word16 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Word32 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Double Word64 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Int Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Int8 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Int16 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Int32 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Int64 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Integer Source #

Converts via Rational when the input is between -16,777,215 and 16,777,215 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Float Natural Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Rational Source #

Uses toRational when the input is not NaN or infinity.

Instance details

Defined in Witch.Instances

TryFrom Float Word Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Word8 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Word16 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Word32 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Float Word64 Source #

Converts via Integer.

Instance details

Defined in Witch.Instances

TryFrom Int Double Source #

Uses fromIntegral when the input is between -9,007,199,254,740,991 and 9,007,199,254,740,991 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Int Float Source #

Uses fromIntegral when the input is between -16,777,215 and 16,777,215 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Int Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Natural Source #

Uses fromIntegral when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Int Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int8 Natural Source #

Uses fromIntegral when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Int8 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int8 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int8 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int8 Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int8 Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Natural Source #

Uses fromIntegral when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Int16 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int16 Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Float Source #

Uses fromIntegral when the input is between -16,777,215 and 16,777,215 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Int32 Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Natural Source #

Uses fromIntegral when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Int32 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int32 Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Double Source #

Uses fromIntegral when the input is between -9,007,199,254,740,991 and 9,007,199,254,740,991 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Int64 Float Source #

Uses fromIntegral when the input is between -16,777,215 and 16,777,215 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Int64 Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Natural Source #

Uses fromIntegral when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Int64 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Int64 Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Double Source #

Uses fromIntegral when the input is between -9,007,199,254,740,991 and 9,007,199,254,740,991 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Integer Float Source #

Uses fromIntegral when the input is between -16,777,215 and 16,777,215 inclusive.

Instance details

Defined in Witch.Instances

TryFrom Integer Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Int64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Natural Source #

Uses fromInteger when the input is not negative.

Instance details

Defined in Witch.Instances

TryFrom Integer Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Integer Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Double Source #

Uses fromIntegral when the input is less than or equal to 9,007,199,254,740,991.

Instance details

Defined in Witch.Instances

TryFrom Natural Float Source #

Uses fromIntegral when the input is less than or equal to 16,777,215.

Instance details

Defined in Witch.Instances

TryFrom Natural Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Int64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Natural Word64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Double Source #

Uses fromIntegral when the input is less than or equal to 9,007,199,254,740,991.

Instance details

Defined in Witch.Instances

TryFrom Word Float Source #

Uses fromIntegral when the input is less than or equal to 16,777,215.

Instance details

Defined in Witch.Instances

TryFrom Word Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Int64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word8 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word16 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word16 Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word16 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Float Source #

Uses fromIntegral when the input is less than or equal to 16,777,215.

Instance details

Defined in Witch.Instances

TryFrom Word32 Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word32 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Double Source #

Uses fromIntegral when the input is less than or equal to 9,007,199,254,740,991.

Instance details

Defined in Witch.Instances

TryFrom Word64 Float Source #

Uses fromIntegral when the input is less than or equal to 16,777,215.

Instance details

Defined in Witch.Instances

TryFrom Word64 Int Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Int8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Int16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Int32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Int64 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Word Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Word8 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Word16 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom Word64 Word32 Source #

Uses toIntegralSized.

Instance details

Defined in Witch.Instances

TryFrom ByteString String Source #

Converts via Text.

Instance details

Defined in Witch.Instances

TryFrom ByteString Text Source #

Uses decodeUtf8'.

Instance details

Defined in Witch.Instances

TryFrom ByteString Text Source #

Converts via Text.

Instance details

Defined in Witch.Instances

TryFrom ByteString String Source #

Converts via Text.

Instance details

Defined in Witch.Instances

TryFrom ByteString Text Source #

Converts via Text.

Instance details

Defined in Witch.Instances

TryFrom ByteString Text Source #

Uses decodeUtf8'.

Instance details

Defined in Witch.Instances

HasResolution a => TryFrom Rational (Fixed a) Source #

Uses fromRational as long as there isn't a loss of precision.

Instance details

Defined in Witch.Instances

(Eq a, Num a) => TryFrom (Ratio a) a Source #

Uses numerator when the denominator is 1.

Instance details

Defined in Witch.Instances

Methods

tryFrom :: Ratio a -> Either (TryFromException (Ratio a) a) a Source #

(Eq a, Num a) => TryFrom (Complex a) a Source #

Uses realPart when the imaginary part is 0.

Instance details

Defined in Witch.Instances

TryFrom [a] (NonEmpty a) Source #

Uses nonEmpty.

Instance details

Defined in Witch.Instances

Methods

tryFrom :: [a] -> Either (TryFromException [a] (NonEmpty a)) (NonEmpty a) Source #