basement-0.0.15: Foundation scrap box of array & string
License BSD-style
Maintainer Haskell Foundation
Safe Haskell None
Language Haskell2010

Basement.From

Description

Flexible Type convertion

From is multi parameter type class that allow converting from a to b.

Only type that are valid to convert to another type should be From instance; otherwise TryFrom should be used.

Into (resp TryInto) allows the contrary instances to be able to specify the destination type before the source. This is practical with TypeApplication

Synopsis

Documentation

class From a b where Source #

Class of things that can be converted from a to b.

In a valid instance, the source should be always representable by the destination, otherwise the instance should be using TryFrom

Methods

from :: a -> b Source #

Instances

Instances details
From Int Int64 Source #
Instance details

Defined in Basement.From

From Int8 Int Source #
Instance details

Defined in Basement.From

From Int8 Int16 Source #
Instance details

Defined in Basement.From

From Int8 Int32 Source #
Instance details

Defined in Basement.From

From Int8 Int64 Source #
Instance details

Defined in Basement.From

From Int16 Int Source #
Instance details

Defined in Basement.From

From Int16 Int32 Source #
Instance details

Defined in Basement.From

From Int16 Int64 Source #
Instance details

Defined in Basement.From

From Int32 Int Source #
Instance details

Defined in Basement.From

From Int32 Int64 Source #
Instance details

Defined in Basement.From

From Word Word64 Source #
Instance details

Defined in Basement.From

From Word8 Int Source #
Instance details

Defined in Basement.From

From Word8 Int16 Source #
Instance details

Defined in Basement.From

From Word8 Int32 Source #
Instance details

Defined in Basement.From

From Word8 Int64 Source #
Instance details

Defined in Basement.From

From Word8 Word Source #
Instance details

Defined in Basement.From

From Word8 Word16 Source #
Instance details

Defined in Basement.From

From Word8 Word32 Source #
Instance details

Defined in Basement.From

From Word8 Word64 Source #
Instance details

Defined in Basement.From

From Word8 Word128 Source #
Instance details

Defined in Basement.From

From Word8 Word256 Source #
Instance details

Defined in Basement.From

From Word16 Int Source #
Instance details

Defined in Basement.From

From Word16 Int32 Source #
Instance details

Defined in Basement.From

From Word16 Int64 Source #
Instance details

Defined in Basement.From

From Word16 Word Source #
Instance details

Defined in Basement.From

From Word16 Word32 Source #
Instance details

Defined in Basement.From

From Word16 Word64 Source #
Instance details

Defined in Basement.From

From Word16 Word128 Source #
Instance details

Defined in Basement.From

From Word16 Word256 Source #
Instance details

Defined in Basement.From

From Word32 Int Source #
Instance details

Defined in Basement.From

From Word32 Int64 Source #
Instance details

Defined in Basement.From

From Word32 Word Source #
Instance details

Defined in Basement.From

From Word32 Word64 Source #
Instance details

Defined in Basement.From

From Word32 Word128 Source #
Instance details

Defined in Basement.From

From Word32 Word256 Source #
Instance details

Defined in Basement.From

From Word64 Word128 Source #
Instance details

Defined in Basement.From

From Word64 Word256 Source #
Instance details

Defined in Basement.From

IsIntegral n => From n Integer Source #
Instance details

Defined in Basement.From

IsNatural n => From n Natural Source #
Instance details

Defined in Basement.From

From a a Source #
Instance details

Defined in Basement.From

Methods

from :: a -> a Source #

From Word128 Word256 Source #
Instance details

Defined in Basement.From

From AsciiString String Source #
Instance details

Defined in Basement.From

From Word ( CountOf ty) Source #
Instance details

Defined in Basement.From

From Word ( Offset ty) Source #
Instance details

Defined in Basement.From

From AsciiString ( UArray Word8 ) Source #
Instance details

Defined in Basement.From

From String ( UArray Word8 ) Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word256 n) => From ( Zn n) Word256 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word128 n) => From ( Zn n) Word128 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word64 n) => From ( Zn n) Word64 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word32 n) => From ( Zn n) Word32 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word16 n) => From ( Zn n) Word16 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word8 n) => From ( Zn n) Word8 Source #
Instance details

Defined in Basement.From

From ( Zn64 n) Word256 Source #
Instance details

Defined in Basement.From

From ( Zn64 n) Word128 Source #
Instance details

Defined in Basement.From

From ( Zn64 n) Word64 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word32 n) => From ( Zn64 n) Word32 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word16 n) => From ( Zn64 n) Word16 Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word8 n) => From ( Zn64 n) Word8 Source #
Instance details

Defined in Basement.From

From ( CountOf ty) Word Source #
Instance details

Defined in Basement.From

From ( CountOf ty) Int Source #
Instance details

Defined in Basement.From

( KnownNat n, NatWithinBound Word64 n) => From ( Zn n) ( Zn64 n) Source #
Instance details

Defined in Basement.From

KnownNat n => From ( Zn64 n) ( Zn n) Source #
Instance details

Defined in Basement.From

PrimType ty => From ( Block ty) ( UArray ty) Source #
Instance details

Defined in Basement.From

PrimType ty => From ( UArray ty) ( Array ty) Source #
Instance details

Defined in Basement.From

PrimType ty => From ( UArray ty) ( Block ty) Source #
Instance details

Defined in Basement.From

PrimType ty => From ( Array ty) ( Block ty) Source #
Instance details

Defined in Basement.From

PrimType ty => From ( Array ty) ( UArray ty) Source #
Instance details

Defined in Basement.From

From ( Maybe a) ( Either () a) Source #
Instance details

Defined in Basement.From

( NatWithinBound Int n, PrimType ty) => From ( BlockN n ty) ( Array ty) Source #
Instance details

Defined in Basement.From

( NatWithinBound Int n, PrimType ty) => From ( BlockN n ty) ( UArray ty) Source #
Instance details

Defined in Basement.From

From ( BlockN n ty) ( Block ty) Source #
Instance details

Defined in Basement.From

From ( Either a b) ( These a b) Source #
Instance details

Defined in Basement.From

( PrimType a, PrimType b, KnownNat n, KnownNat m, ( PrimSize b * m) ~ ( PrimSize a * n)) => From ( BlockN n a) ( BlockN m b) Source #
Instance details

Defined in Basement.From

into :: Into b a => a -> b Source #

Same as from but reverse the type variable so that the destination type can be specified first

e.g. converting:

from _ Word (10 :: Int)

into @Word (10 :: Int)

tryInto :: TryInto b a => a -> Maybe b Source #

same as tryFrom but reversed