si-bytes-0.1: Byte with type-level units (e.g. B, KB, MB, ...).
Safe HaskellNone
LanguageHaskell2010

Data.Bytes

Description

This module serves as the main entry point for the library. It provides the types and operations for typical usage and is usually the only import required. The core concept is:

  1. Wrapping a numeric value representing bytes in a new type.
  2. Attaching phantom labels representing the units (e.g. K, M, ...).

This prevents mistakes, such as adding two different byte sizes or converting between sizes incorrectly.

Since: 0.1

Synopsis

Introduction

The main idea is to attach phantom labels to the numeric bytes, so we can track the size units. This allows us to safely manipulate byte values without mixing up units, performing incorrect conversions, etc.

The core types are a newtype wrapper Bytes and the Size units:

newtype Bytes (s :: Size) n Source #

This is the core type for handling type-safe byte operations. It is intended to be used as a simple wrapper over some numeric type, equipped with a Size tag.

To take full advantage of the API (e.g. normalize), the underlying numeric type should implement Semifield or, ideally, Field.

Examples

Expand
>>> MkBytes @M 1000
MkBytes 1000

Since: 0.1

Constructors

MkBytes n 

Instances

Instances details
HasField "unBytes" (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

getField :: Bytes s n -> n #

(k ~ An_Iso, a ~ n, b ~ n) => LabelOptic "unBytes" k (Bytes s n) (Bytes s n) a b Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

labelOptic :: Optic k NoIx (Bytes s n) (Bytes s n) a b Source #

Applicative (Bytes s) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

pure :: a -> Bytes s a #

(<*>) :: Bytes s (a -> b) -> Bytes s a -> Bytes s b #

liftA2 :: (a -> b -> c) -> Bytes s a -> Bytes s b -> Bytes s c #

(*>) :: Bytes s a -> Bytes s b -> Bytes s b #

(<*) :: Bytes s a -> Bytes s b -> Bytes s a #

Functor (Bytes s) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

fmap :: (a -> b) -> Bytes s a -> Bytes s b #

(<$) :: a -> Bytes s b -> Bytes s a #

Monad (Bytes s) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(>>=) :: Bytes s a -> (a -> Bytes s b) -> Bytes s b #

(>>) :: Bytes s a -> Bytes s b -> Bytes s b #

return :: a -> Bytes s a #

Foldable (Bytes s) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

fold :: Monoid m => Bytes s m -> m #

foldMap :: Monoid m => (a -> m) -> Bytes s a -> m #

foldMap' :: Monoid m => (a -> m) -> Bytes s a -> m #

foldr :: (a -> b -> b) -> b -> Bytes s a -> b #

foldr' :: (a -> b -> b) -> b -> Bytes s a -> b #

foldl :: (b -> a -> b) -> b -> Bytes s a -> b #

foldl' :: (b -> a -> b) -> b -> Bytes s a -> b #

foldr1 :: (a -> a -> a) -> Bytes s a -> a #

foldl1 :: (a -> a -> a) -> Bytes s a -> a #

toList :: Bytes s a -> [a] #

null :: Bytes s a -> Bool #

length :: Bytes s a -> Int #

elem :: Eq a => a -> Bytes s a -> Bool #

maximum :: Ord a => Bytes s a -> a #

minimum :: Ord a => Bytes s a -> a #

sum :: Num a => Bytes s a -> a #

product :: Num a => Bytes s a -> a #

Traversable (Bytes s) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Bytes s a -> f (Bytes s b) #

sequenceA :: Applicative f => Bytes s (f a) -> f (Bytes s a) #

mapM :: Monad m => (a -> m b) -> Bytes s a -> m (Bytes s b) #

sequence :: Monad m => Bytes s (m a) -> m (Bytes s a) #

AGroup n => AGroup (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.-.) :: Bytes s n -> Bytes s n -> Bytes s n Source #

AMonoid n => AMonoid (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

zero :: Bytes s n Source #

ASemigroup n => ASemigroup (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.+.) :: Bytes s n -> Bytes s n -> Bytes s n Source #

Normed n => Normed (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

norm :: Bytes s n -> Bytes s n Source #

FromInteger n => FromInteger (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

afromInteger :: Integer -> Bytes s n Source #

FromRational n => FromRational (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

AnyLowerBounded n => AnyLowerBounded (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

AnyUpperBounded n => AnyUpperBounded (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

LowerBounded n => LowerBounded (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

lowerBound :: Bytes s n Source #

LowerBoundless (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

UpperBounded n => UpperBounded (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

upperBound :: Bytes s n Source #

UpperBoundless (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

NFData n => NFData (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

rnf :: Bytes s n -> () #

Bounded n => Bounded (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

minBound :: Bytes s n #

maxBound :: Bytes s n #

Generic (Bytes s n) Source # 
Instance details

Defined in Data.Bytes.Internal

Associated Types

type Rep (Bytes s n)

Since: si-bytes-0.1

Instance details

Defined in Data.Bytes.Internal

type Rep (Bytes s n) = D1 ('MetaData "Bytes" "Data.Bytes.Internal" "si-bytes-0.1-inplace" 'True) (C1 ('MetaCons "MkBytes" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n)))

Methods

from :: Bytes s n -> Rep (Bytes s n) x #

to :: Rep (Bytes s n) x -> Bytes s n #

Show n => Show (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

showsPrec :: Int -> Bytes s n -> ShowS #

show :: Bytes s n -> String #

showList :: [Bytes s n] -> ShowS #

Eq n => Eq (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(==) :: Bytes s n -> Bytes s n -> Bool #

(/=) :: Bytes s n -> Bytes s n -> Bool #

Ord n => Ord (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

compare :: Bytes s n -> Bytes s n -> Ordering #

(<) :: Bytes s n -> Bytes s n -> Bool #

(<=) :: Bytes s n -> Bytes s n -> Bool #

(>) :: Bytes s n -> Bytes s n -> Bool #

(>=) :: Bytes s n -> Bytes s n -> Bool #

max :: Bytes s n -> Bytes s n -> Bytes s n #

min :: Bytes s n -> Bytes s n -> Bytes s n #

Hashable n => Hashable (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

hashWithSalt :: Int -> Bytes s n -> Int Source #

hash :: Bytes s n -> Int Source #

(FromInteger n, MGroup n, SingSize s) => Conversion (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => Bytes s n -> Converted t (Bytes s n) Source #

(FromInteger n, MGroup n, Normed n, Ord n, SingSize s) => Normalize (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Norm (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type Norm (Bytes s n) = SomeSize n

Methods

normalize :: Bytes s n -> Norm (Bytes s n) Source #

Read n => Parser (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

parser :: Parsec Void Text (Bytes s n) Source #

RawNumeric (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Raw (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type Raw (Bytes s n) = n

Methods

toRaw :: Bytes s n -> Raw (Bytes s n) Source #

SingSize s => Sized (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type HideSize (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type HideSize (Bytes s n) = SomeSize n

Methods

sizeOf :: Bytes s n -> Size Source #

hideSize :: Bytes s n -> HideSize (Bytes s n) Source #

MSemigroup n => MSemiSpace (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.*) :: Bytes s n -> n -> Bytes s n Source #

MGroup n => MSpace (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.%) :: Bytes s n -> n -> Bytes s n Source #

Ring n => Module (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Semiring n => Semimodule (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Semifield n => SemivectorSpace (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Field n => VectorSpace (Bytes s n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

type Converted t (Bytes s n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Converted t (Bytes s n) = Bytes t n
type Rep (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

type Rep (Bytes s n) = D1 ('MetaData "Bytes" "Data.Bytes.Internal" "si-bytes-0.1-inplace" 'True) (C1 ('MetaCons "MkBytes" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n)))
type Norm (Bytes s n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Norm (Bytes s n) = SomeSize n
type Raw (Bytes s n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Raw (Bytes s n) = n
type HideSize (Bytes s n) Source # 
Instance details

Defined in Data.Bytes.Internal

type HideSize (Bytes s n) = SomeSize n

data Size Source #

Byte units.

Since: 0.1

Constructors

B

Bytes

Since: 0.1

K

Kilobytes

Since: 0.1

M

Megabytes

Since: 0.1

G

Gigabytes

Since: 0.1

T

Terabytes

Since: 0.1

P

Petabytes

Since: 0.1

E

Exabytes

Since: 0.1

Z

Zettabytes

Since: 0.1

Y

Yottabytes

Since: 0.1

Instances

Instances details
NFData Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

rnf :: Size -> () #

Bounded Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Enum Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

succ :: Size -> Size #

pred :: Size -> Size #

toEnum :: Int -> Size #

fromEnum :: Size -> Int #

enumFrom :: Size -> [Size] #

enumFromThen :: Size -> Size -> [Size] #

enumFromTo :: Size -> Size -> [Size] #

enumFromThenTo :: Size -> Size -> Size -> [Size] #

Generic Size Source # 
Instance details

Defined in Data.Bytes.Size

Associated Types

type Rep Size

Since: si-bytes-0.1

Instance details

Defined in Data.Bytes.Size

type Rep Size = D1 ('MetaData "Size" "Data.Bytes.Size" "si-bytes-0.1-inplace" 'False) (((C1 ('MetaCons "B" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "K" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "M" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "G" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "T" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "P" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "E" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Z" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Y" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: Size -> Rep Size x #

to :: Rep Size x -> Size #

Show Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

Eq Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Ord Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Hashable Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Parser Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

TestEquality SSize Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Methods

testEquality :: forall (a :: Size) (b :: Size). SSize a -> SSize b -> Maybe (a :~: b) #

type Rep Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

type Rep Size = D1 ('MetaData "Size" "Data.Bytes.Size" "si-bytes-0.1-inplace" 'False) (((C1 ('MetaCons "B" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "K" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "M" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "G" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "T" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "P" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "E" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Z" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Y" 'PrefixI 'False) (U1 :: Type -> Type)))))

Basic Usage

Construction

There are several ways to construct a Bytes type.

  1. FromInteger

    >>> afromInteger 80 :: Bytes M Int
    MkBytes 80
    
  2. Directly

    >>> MkBytes 80 :: Bytes M Int
    MkBytes 80
    
  3. Optics (optics-core)

    >>> import Optics.Core (review)
    >>> (review _MkBytes 70) :: Bytes G Int
    MkBytes 70
    
    >>> (review #unBytes 70) :: Bytes G Int
    MkBytes 70
    

Unknown Size

We sometimes have to deal with unknown sizes at runtime, which presents a problem. We handle this with the SomeSize type, which existentially quantifies the Size:

data SomeSize n Source #

Wrapper for Bytes, existentially quantifying the size. This is useful when a function does not know a priori what size it should return e.g.

>>> :{
  getFileSize :: FilePath -> IO (SomeSize Float)
  getFileSize path = do
    -- getRawFileSize :: FilePath -> IO (Float, String)
    (bytes, units) <- getRawFileSize path
    pure $ case units of
      "B" -> hideSize $ MkBytes @B bytes
      "K" -> hideSize $ MkBytes @K bytes
      _ -> error "todo"
:}

We define an equivalence relation on SomeSize that takes units into account. For instance,

>>> hideSize (MkBytes @G 7) == hideSize (MkBytes @M 7_000)
True

Because we expose the underlying Bytes in several ways (e.g. Show, the SSize witness), this is technically unlawful for equality as it breaks the extensionality law:

\[ x = y \implies f(x) = f(y). \]

Since: 0.1

Instances

Instances details
Functor SomeSize Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

fmap :: (a -> b) -> SomeSize a -> SomeSize b #

(<$) :: a -> SomeSize b -> SomeSize a #

Foldable SomeSize Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

fold :: Monoid m => SomeSize m -> m #

foldMap :: Monoid m => (a -> m) -> SomeSize a -> m #

foldMap' :: Monoid m => (a -> m) -> SomeSize a -> m #

foldr :: (a -> b -> b) -> b -> SomeSize a -> b #

foldr' :: (a -> b -> b) -> b -> SomeSize a -> b #

foldl :: (b -> a -> b) -> b -> SomeSize a -> b #

foldl' :: (b -> a -> b) -> b -> SomeSize a -> b #

foldr1 :: (a -> a -> a) -> SomeSize a -> a #

foldl1 :: (a -> a -> a) -> SomeSize a -> a #

toList :: SomeSize a -> [a] #

null :: SomeSize a -> Bool #

length :: SomeSize a -> Int #

elem :: Eq a => a -> SomeSize a -> Bool #

maximum :: Ord a => SomeSize a -> a #

minimum :: Ord a => SomeSize a -> a #

sum :: Num a => SomeSize a -> a #

product :: Num a => SomeSize a -> a #

Traversable SomeSize Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

traverse :: Applicative f => (a -> f b) -> SomeSize a -> f (SomeSize b) #

sequenceA :: Applicative f => SomeSize (f a) -> f (SomeSize a) #

mapM :: Monad m => (a -> m b) -> SomeSize a -> m (SomeSize b) #

sequence :: Monad m => SomeSize (m a) -> m (SomeSize a) #

HasField "unSomeSize" (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

getField :: SomeSize n -> n #

(k ~ A_Getter, a ~ n, b ~ n) => LabelOptic "unSomeSize" k (SomeSize n) (SomeSize n) a b Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

labelOptic :: Optic k NoIx (SomeSize n) (SomeSize n) a b Source #

(Field n, FromInteger n) => AGroup (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.-.) :: SomeSize n -> SomeSize n -> SomeSize n Source #

(FromInteger n, Semifield n) => AMonoid (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

zero :: SomeSize n Source #

(ASemigroup n, FromInteger n, MGroup n) => ASemigroup (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.+.) :: SomeSize n -> SomeSize n -> SomeSize n Source #

Normed n => Normed (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

norm :: SomeSize n -> SomeSize n Source #

FromInteger n => FromInteger (SomeSize n) Source #

Fixed size B.

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

FromRational n => FromRational (SomeSize n) Source #

Fixed size B.

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

NFData n => NFData (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

rnf :: SomeSize n -> () #

Show n => Show (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

showsPrec :: Int -> SomeSize n -> ShowS #

show :: SomeSize n -> String #

showList :: [SomeSize n] -> ShowS #

(Eq n, FromInteger n, MGroup n) => Eq (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(==) :: SomeSize n -> SomeSize n -> Bool #

(/=) :: SomeSize n -> SomeSize n -> Bool #

(FromInteger n, MGroup n, Ord n) => Ord (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

compare :: SomeSize n -> SomeSize n -> Ordering #

(<) :: SomeSize n -> SomeSize n -> Bool #

(<=) :: SomeSize n -> SomeSize n -> Bool #

(>) :: SomeSize n -> SomeSize n -> Bool #

(>=) :: SomeSize n -> SomeSize n -> Bool #

max :: SomeSize n -> SomeSize n -> SomeSize n #

min :: SomeSize n -> SomeSize n -> SomeSize n #

(FromInteger n, Hashable n, MGroup n) => Hashable (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

(FromInteger n, MGroup n) => Conversion (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => SomeSize n -> Converted t (SomeSize n) Source #

(FromInteger n, MGroup n, Normed n, Ord n) => Normalize (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Norm (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

type Norm (SomeSize n) = SomeSize n

Methods

normalize :: SomeSize n -> Norm (SomeSize n) Source #

Read n => Parser (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

RawNumeric (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Raw (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

type Raw (SomeSize n) = n

Methods

toRaw :: SomeSize n -> Raw (SomeSize n) Source #

Sized (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type HideSize (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

MGroup n => MSemiSpace (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.*) :: SomeSize n -> n -> SomeSize n Source #

MGroup n => MSpace (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

(.%) :: SomeSize n -> n -> SomeSize n Source #

(Field n, FromInteger n) => Module (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

(FromInteger n, Semifield n) => Semimodule (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

(FromInteger n, Semifield n) => SemivectorSpace (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

(Field n, FromInteger n) => VectorSpace (SomeSize n) n Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

type Converted t (SomeSize n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Converted t (SomeSize n) = Bytes t n
type Norm (SomeSize n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Norm (SomeSize n) = SomeSize n
type Raw (SomeSize n) Source # 
Instance details

Defined in Data.Bytes.Internal

type Raw (SomeSize n) = n
type HideSize (SomeSize n) Source # 
Instance details

Defined in Data.Bytes.Internal

Sized

Fortunately, we do not have to directly use the constructor or singletons. We can instead use the Sized class.

class Sized a where Source #

Types that have a size.

Since: 0.1

Associated Types

type HideSize a Source #

Type used to hide the size.

Since: 0.1

Methods

sizeOf :: a -> Size Source #

Retrieves the size.

Examples

Expand
>>> import Data.Bytes (Bytes (..))
>>> sizeOf (MkBytes @G 7)
G
>>> sizeOf (hideSize $ MkBytes @M 7)
M
>>> import Data.Bytes.Network (NetBytes (..), Direction (..))
>>> sizeOf (hideSize $ MkNetBytesP @Up @M 7)
M

Since: 0.1

hideSize :: a -> HideSize a Source #

Hides the size.

Examples

Expand
>>> import Data.Bytes (Bytes (..))
>>> hideSize (MkBytes @G 7)
MkSomeSize SG (MkBytes 7)

Instances

Instances details
Sized (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type HideSize (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

Sized (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideSize (SomeNet n) 
Instance details

Defined in Data.Bytes.Network.Internal

type HideSize (SomeNet n) = SomeNet n
SingSize s => Sized (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type HideSize (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type HideSize (Bytes s n) = SomeSize n

Methods

sizeOf :: Bytes s n -> Size Source #

hideSize :: Bytes s n -> HideSize (Bytes s n) Source #

SingSize s => Sized (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideSize (SomeNetDir s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type HideSize (SomeNetDir s n) = SomeNet n
Sized (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideSize (SomeNetSize d n) 
Instance details

Defined in Data.Bytes.Network.Internal

SingSize s => Sized (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideSize (NetBytes d s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type HideSize (NetBytes d s n) = SomeNetSize d n

Methods

sizeOf :: NetBytes d s n -> Size Source #

hideSize :: NetBytes d s n -> HideSize (NetBytes d s n) Source #

Optics

Once again, we can use optics for this.

>>> import Optics.Core (review)
>>> review _MkSomeSize (MkBytes 70 :: Bytes G Int)
MkSomeSize SG (MkBytes 70)

Elimination

RawNumeric

We provide the RawNumeric class for conveniently unwrapping a type to the underlying numeric value.

class RawNumeric a where Source #

Abstracts "wrapper" types for generically retrieving a raw numeric value.

Since: 0.1

Associated Types

type Raw a Source #

Since: 0.1

Methods

toRaw :: a -> Raw a Source #

Retrieves the underlying value.

Examples

Expand
>>> import Data.Bytes (Bytes (..), Size (..), Sized (..))
>>> toRaw (MkBytes @G 7)
7
>>> toRaw (hideSize $ MkBytes @M 400)
400
>>> import Data.Bytes.Network (Direction (..), NetBytes (..))
>>> toRaw (MkNetBytesP @Up @G 7)
7
>>> toRaw (hideSize $ MkNetBytesP @Up @G 7)
7

Since: 0.1

Instances

Instances details
RawNumeric (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Raw (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

type Raw (SomeSize n) = n

Methods

toRaw :: SomeSize n -> Raw (SomeSize n) Source #

RawNumeric (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Raw (SomeNet n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Raw (SomeNet n) = n

Methods

toRaw :: SomeNet n -> Raw (SomeNet n) Source #

RawNumeric (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Raw (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type Raw (Bytes s n) = n

Methods

toRaw :: Bytes s n -> Raw (Bytes s n) Source #

RawNumeric (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Raw (SomeNetDir s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Raw (SomeNetDir s n) = n

Methods

toRaw :: SomeNetDir s n -> Raw (SomeNetDir s n) Source #

RawNumeric (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Raw (SomeNetSize d n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Raw (SomeNetSize d n) = n

Methods

toRaw :: SomeNetSize d n -> Raw (SomeNetSize d n) Source #

RawNumeric (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Raw (NetBytes d s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Raw (NetBytes d s n) = n

Methods

toRaw :: NetBytes d s n -> Raw (NetBytes d s n) Source #

HasField

We can use HasField for this too.

>>> -- {-# LANGUAGE OverloadedRecordDot #-}
>>> let x = MkBytes 7 :: Bytes G Int
>>> x.unBytes
7
>>> let y = hideSize x :: SomeSize Int
>>> y.unSomeSize
7

Optics

Optics are another option. The underscore-prefixed optics unwrap one level at a time, since we can freely compose them.

>>> import Optics.Core (view, (%))
>>> let x = MkBytes 7 :: Bytes G Int
>>> view _MkBytes x
7
>>> -- notice we have to convert the numeric value since the requested
>>> -- return type ('M') differs from the original ('G')
>>> let y = hideSize x :: SomeSize Int
>>> (view _MkSomeSize y) :: Bytes M Int
MkBytes 7000
>>> view (_MkSomeSize % (_MkBytes @M)) y
7000

The -XOverloadedLabel instances unwrap all the way to the underlying numeric value.

>>> view #unBytes x
7
>>> view #unSomeSize y
7

Transformations

Converting Units

class Conversion a where Source #

This class allows one to transform a bytes type to any Size. For types with existentially quantified Size (e.g. SomeSize, SomeNetSize), this will "undo" the existential quantification.

Since: 0.1

Associated Types

type Converted (t :: Size) a = (r :: Type) | r -> t Source #

Since: 0.1

Methods

convert_ :: forall (t :: Size). SingSize t => a -> Converted t a Source #

convert_ @_ @t x converts x to size t.

Examples

Expand
>>> let bytes = MkBytes 50_000 :: Bytes 'M Int
>>> let gBytes = convert_ @_ @G bytes
>>> :type gBytes
gBytes :: Bytes G Int
>>> gBytes
MkBytes 50
>>> let bytes = hideSize (MkBytes 0.2 :: Bytes 'T Float)
>>> let mBytes = convert_ @_ @M bytes
>>> :type mBytes
mBytes :: Bytes M Float
>>> mBytes
MkBytes 200000.0

Since: 0.1

Instances

Instances details
(FromInteger n, MGroup n) => Conversion (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => SomeSize n -> Converted t (SomeSize n) Source #

(FromInteger n, MGroup n) => Conversion (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => SomeNet n -> Converted t (SomeNet n) Source #

(FromInteger n, MGroup n, SingSize s) => Conversion (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => Bytes s n -> Converted t (Bytes s n) Source #

(FromInteger n, MGroup n, SingSize s) => Conversion (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => SomeNetDir s n -> Converted t (SomeNetDir s n) Source #

(FromInteger n, MGroup n) => Conversion (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => SomeNetSize d n -> Converted t (SomeNetSize d n) Source #

(FromInteger n, MGroup n, SingSize s) => Conversion (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Methods

convert_ :: forall (t :: Size). SingSize t => NetBytes d s n -> Converted t (NetBytes d s n) Source #

convert :: forall (t :: Size) -> SingSize t => forall a. Conversion a => a -> Converted t a Source #

Alternative to convert_ with -XTypeApplications, using -XRequiredTypeArguments.

Examples

Expand
>>> let bytes = MkBytes 50_000 :: Bytes 'M Int
>>> let gBytes = convert G bytes
>>> :type gBytes
gBytes :: Bytes G Int
>>> gBytes
MkBytes 50

Since: 0.1

Normalization

class Normalize a where Source #

Used for normalizing bytes b such that

\[ 1 \le \text{normalize}(b) < 1000 \iff 1\text{ B} \le b < 1000\text{ Y}. \]

In the strictest sense, \(\textrm{normalize} : \mathcal{C} \rightarrow \mathcal{C}\) is not a homomorphism, as the combination of two normalized values may itself not be normalized.

However, because the normalized units varies with the value, normalize always returns a type that existentially quantifies the size (e.g. SomeSize). Eq for these types is defined in terms of an equivalence class that takes units into account e.g. 1 P = 1,000 T = 1,000,000 G .... Viewed this way, normalize is actually an isomorphism, as it is essentially a no-op, never leaving the equivalence class.

This means we can happily mix normalization with different functions without worrying about the order. The only requirement we have is that such functions respect substitution:

\[ x = y \implies f(x) = f(y). \]

This is certainly true for all the usual mathematical operations we would normally use, e.g., AGroup addition, Module scalar multiplication. On the other hand, any functions that inspect the underlying numeric value or Bytes types could easily break this law. As such they should be treated with suspicion, at least when used in conjunction with normalize.

The other consideration we must keep in mind is that the final result of a series of computations may not be normalized. If this is desired, then normalize should be the last operation performed. Using normalize in the middle would not cause any harm (other than, perhaps, impacting efficiency), but it would not guarantee the final result is normalized.

Since: 0.1

Associated Types

type Norm a Source #

Since: 0.1

Methods

normalize :: a -> Norm a Source #

Normalizes the value.

Examples

Expand
>>> let bytes = MkBytes 5000 :: Bytes 'M Int
>>> normalize bytes
MkSomeSize SG (MkBytes 5)
>>> let bytes = hideSize (MkBytes 0.01 :: Bytes 'T Float)
>>> normalize bytes
MkSomeSize SG (MkBytes 10.0)

Since: 0.1

Instances

Instances details
(FromInteger n, MGroup n, Normed n, Ord n) => Normalize (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Norm (SomeSize n) 
Instance details

Defined in Data.Bytes.Internal

type Norm (SomeSize n) = SomeSize n

Methods

normalize :: SomeSize n -> Norm (SomeSize n) Source #

(FromInteger n, MGroup n, Normed n, Ord n) => Normalize (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Norm (SomeNet n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Norm (SomeNet n) = SomeNet n

Methods

normalize :: SomeNet n -> Norm (SomeNet n) Source #

(FromInteger n, MGroup n, Normed n, Ord n, SingSize s) => Normalize (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Associated Types

type Norm (Bytes s n) 
Instance details

Defined in Data.Bytes.Internal

type Norm (Bytes s n) = SomeSize n

Methods

normalize :: Bytes s n -> Norm (Bytes s n) Source #

(FromInteger n, MGroup n, Normed n, Ord n, SingSize s) => Normalize (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Norm (SomeNetDir s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Norm (SomeNetDir s n) = SomeNet n

Methods

normalize :: SomeNetDir s n -> Norm (SomeNetDir s n) Source #

(FromInteger n, MGroup n, Normed n, Ord n) => Normalize (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Norm (SomeNetSize d n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Norm (SomeNetSize d n) = SomeNetSize d n

Methods

normalize :: SomeNetSize d n -> Norm (SomeNetSize d n) Source #

(FromInteger n, MGroup n, Normed n, Ord n, SingSize s) => Normalize (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type Norm (NetBytes d s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type Norm (NetBytes d s n) = SomeNetSize d n

Methods

normalize :: NetBytes d s n -> Norm (NetBytes d s n) Source #

Algebra

The built-in Num class is abandoned in favor of algebra-simple's algebraic hierarchy based on abstract algebra. This is motivated by a desire to:

  1. Provide a consistent API.
  2. Avoid Num's infelicities (e.g. nonsense multiplication, dangerous fromInteger).

Bytes and SomeSize are both AGroups. A Ring instance is not provided because multiplication is nonsensical:

\[ x \;\textrm{mb} \times y \;\textrm{mb} = xy \;\textrm{mb}^2. \]

Fortunately, multiplying bytes by some kind of scalar is both useful and has an easy interpretation: Bytes forms a Module over a Ring (resp. VectorSpace over a Field). This allows us to multiply a Bytes or SomeSize by a scalar in a manner consistent with the above API.

Examples

Addition/Subtraction

>>> import Numeric.Algebra (ASemigroup ((.+.)), AGroup ((.-.)))
>>> let mb1 = MkBytes 20 :: Bytes 'M Int
>>> let mb2 = MkBytes 50 :: Bytes 'M Int
>>> mb1 .+. mb2
MkBytes 70
>>> mb1 .-. mb2
MkBytes (-30)
>>> let kb = MkBytes 50 :: Bytes 'K Int
>>> -- mb1 .+. kb -- This would be a type error

Multiplication

>>> import Numeric.Algebra (MSemiSpace ((.*)))
>>> mb1 .* 10
MkBytes 200

Division

>>> import Numeric.Algebra (MSpace ((.%)))
>>> mb1 .% 10
MkBytes 2

One may wonder how the AGroup instance for SomeSize could possibly work. It is possible (indeed, expected) that we could have two SomeSizes that have different underlying Bytes types. To handle this, the SomeSize instance will convert both Bytes to a Bytes 'B before adding/subtracting.

>>> let some1 = hideSize (MkBytes 1000 :: Bytes 'G Double)
>>> let some2 = hideSize (MkBytes 500_000 :: Bytes 'M Double)
>>> some1 .+. some2
MkSomeSize SB (MkBytes 1.5e12)
>>> some1 .-. some2
MkSomeSize SB (MkBytes 5.0e11)

This respects SomeSize's equivalence-class based Eq.

Text

Pretty Printing

We provide several formatters for pretty-printing different byte types.

>>> import Data.Default (Default (def))
>>> let bf = MkFloatingFormatter (Just 2)
>>> let b = MkBytes @G @Float 20.248
>>> formatSized bf def b
"20.25 gb"

Parsing

class Parser a Source #

Represents a megaparsec parser. Used for parsing byte types from Text.

Since: 0.1

Minimal complete definition

parser

Instances

Instances details
Parser Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Parser Size Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Size

Read n => Parser (SomeSize n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Read n => Parser (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Read n => Parser (Bytes s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Internal

Methods

parser :: Parsec Void Text (Bytes s n) Source #

Read n => Parser (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Read n => Parser (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Read n => Parser (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Methods

parser :: Parsec Void Text (NetBytes d s n) Source #

parse :: Parser a => Text -> Either Text a Source #

Parses various byte types from Text. Parsing is lenient in general. We support:

  • Case-insensitivity.
  • Optional leading/internal/trailing whitespace.
  • Flexible names.

Bytes Examples

Expand
>>> import Data.Bytes (Bytes, Size (..), SomeSize)
>>> parse @(Bytes M Int) "70"
Right (MkBytes 70)
>>> parse @(SomeSize Float) "100.45 kilobytes"
Right (MkSomeSize SK (MkBytes 100.45))
>>> parse @(SomeSize Word) "2300G"
Right (MkSomeSize SG (MkBytes 2300))
>>> parse @(SomeSize Float) "5.5 tb"
Right (MkSomeSize ST (MkBytes 5.5))

Network Examples

Expand
>>> import Data.Bytes.Network (Direction (..), NetBytes, SomeNet, SomeNetDir, SomeNetSize)
>>> parse @(NetBytes Up M Int) "70"
Right (MkNetBytes (MkBytes 70))
>>> parse @(SomeNetSize Down Float) "100.45 kilobytes"
Right (MkSomeNetSize SK (MkNetBytes (MkBytes 100.45)))
>>> parse @(SomeNetSize Up Word) "2300G"
Right (MkSomeNetSize SG (MkNetBytes (MkBytes 2300)))
>>> parse @(SomeNetDir T Word) "2300 up"
Right (MkSomeNetDir SUp (MkNetBytes (MkBytes 2300)))
>>> parse @(SomeNetDir M Word) "2300D"
Right (MkSomeNetDir SDown (MkNetBytes (MkBytes 2300)))
>>> parse @(SomeNet Float) "5.5 tb Up"
Right (MkSomeNet SUp ST (MkNetBytes (MkBytes 5.5)))
>>> parse @(SomeNet Float) "5.5 megabytes DOWN"
Right (MkSomeNet SDown SM (MkNetBytes (MkBytes 5.5)))

Since: 0.1

Optics

Core

_MkBytes :: forall (s :: Size) n. Iso' (Bytes s n) n Source #

Iso' between Bytes and underlying value.

Examples

Expand
>>> import Optics.Core (review, view)
>>> (review _MkBytes 70) :: Bytes K Int
MkBytes 70
>>> view _MkBytes (MkBytes @K @Int 70)
70

Since: 0.1

_MkSomeSize :: forall (s :: Size) n. (FromInteger n, MGroup n, SingSize s) => Iso' (SomeSize n) (Bytes s n) Source #

Iso' between SomeSize and underlying Bytes. Performs any necessary conversions when going from SomeSize n -> Bytes s n.

Examples

Expand
>>> import Optics.Core (review, view)
>>> review _MkSomeSize (MkBytes @K @Int 70)
MkSomeSize SK (MkBytes 70)
>>> (view _MkSomeSize (hideSize $ MkBytes @K @Int 70)) :: Bytes B Int
MkBytes 70000

Since: 0.1

Size

_B :: Prism' Size () Source #

Since: 0.1

_K :: Prism' Size () Source #

Since: 0.1

_M :: Prism' Size () Source #

Since: 0.1

_G :: Prism' Size () Source #

Since: 0.1

_T :: Prism' Size () Source #

Since: 0.1

_P :: Prism' Size () Source #

Since: 0.1

_E :: Prism' Size () Source #

Since: 0.1

_Z :: Prism' Size () Source #

Since: 0.1

_Y :: Prism' Size () Source #

Since: 0.1

Reexports

class Default a where Source #

A class for types with a default value.

Minimal complete definition

Nothing

Methods

def :: a Source #

The default value for this type.

default def :: (Generic a, GDefault (Rep a)) => a Source #

Instances

Instances details
Default All 
Instance details

Defined in Data.Default.Class

Methods

def :: All Source #

Default Any 
Instance details

Defined in Data.Default.Class

Methods

def :: Any Source #

Default CClock 
Instance details

Defined in Data.Default.Class

Methods

def :: CClock Source #

Default CDouble 
Instance details

Defined in Data.Default.Class

Methods

def :: CDouble Source #

Default CFloat 
Instance details

Defined in Data.Default.Class

Methods

def :: CFloat Source #

Default CInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CInt Source #

Default CIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntMax Source #

Default CIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntPtr Source #

Default CLLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLLong Source #

Default CLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLong Source #

Default CPtrdiff 
Instance details

Defined in Data.Default.Class

Methods

def :: CPtrdiff Source #

Default CSUSeconds 
Instance details

Defined in Data.Default.Class

Default CShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CShort Source #

Default CSigAtomic 
Instance details

Defined in Data.Default.Class

Default CSize 
Instance details

Defined in Data.Default.Class

Methods

def :: CSize Source #

Default CTime 
Instance details

Defined in Data.Default.Class

Methods

def :: CTime Source #

Default CUInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CUInt Source #

Default CUIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntMax Source #

Default CUIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntPtr Source #

Default CULLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULLong Source #

Default CULong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULong Source #

Default CUSeconds 
Instance details

Defined in Data.Default.Class

Methods

def :: CUSeconds Source #

Default CUShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CUShort Source #

Default Int16 
Instance details

Defined in Data.Default.Class

Methods

def :: Int16 Source #

Default Int32 
Instance details

Defined in Data.Default.Class

Methods

def :: Int32 Source #

Default Int64 
Instance details

Defined in Data.Default.Class

Methods

def :: Int64 Source #

Default Int8 
Instance details

Defined in Data.Default.Class

Methods

def :: Int8 Source #

Default Word16 
Instance details

Defined in Data.Default.Class

Methods

def :: Word16 Source #

Default Word32 
Instance details

Defined in Data.Default.Class

Methods

def :: Word32 Source #

Default Word64 
Instance details

Defined in Data.Default.Class

Methods

def :: Word64 Source #

Default Word8 
Instance details

Defined in Data.Default.Class

Methods

def :: Word8 Source #

Default Ordering 
Instance details

Defined in Data.Default.Class

Methods

def :: Ordering Source #

Default DirectedFormatter Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Formatting.Direction

Default DirectionFormat Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Formatting.Direction

Default SizeFormat Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Formatting.Size

Default SizedFormatter Source # 
Instance details

Defined in Data.Bytes.Formatting.Size

Default Integer 
Instance details

Defined in Data.Default.Class

Methods

def :: Integer Source #

Default () 
Instance details

Defined in Data.Default.Class

Methods

def :: () Source #

Default Double 
Instance details

Defined in Data.Default.Class

Methods

def :: Double Source #

Default Float 
Instance details

Defined in Data.Default.Class

Methods

def :: Float Source #

Default Int 
Instance details

Defined in Data.Default.Class

Methods

def :: Int Source #

Default Word 
Instance details

Defined in Data.Default.Class

Methods

def :: Word Source #

(Default a, RealFloat a) => Default (Complex a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Complex a Source #

Default (First a) 
Instance details

Defined in Data.Default.Class

Methods

def :: First a Source #

Default (Last a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Last a Source #

Default a => Default (Dual a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Dual a Source #

Default (Endo a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Endo a Source #

Num a => Default (Product a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Product a Source #

Num a => Default (Sum a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Sum a Source #

Integral a => Default (Ratio a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Ratio a Source #

Default a => Default (IO a) 
Instance details

Defined in Data.Default.Class

Methods

def :: IO a Source #

Default (Maybe a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Maybe a Source #

Default [a] 
Instance details

Defined in Data.Default.Class

Methods

def :: [a] Source #

(Default a, Default b) => Default (a, b) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b) Source #

Default r => Default (e -> r) 
Instance details

Defined in Data.Default.Class

Methods

def :: e -> r Source #

(Default a, Default b, Default c) => Default (a, b, c) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c) Source #

(Default a, Default b, Default c, Default d) => Default (a, b, c, d) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d) Source #

(Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e) Source #

(Default a, Default b, Default c, Default d, Default e, Default f) => Default (a, b, c, d, e, f) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f) Source #

(Default a, Default b, Default c, Default d, Default e, Default f, Default g) => Default (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f, g) Source #