Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides the Size
type and typeclasses for converting
between units.
Since: 0.1
Synopsis
- data Size
- data SSize (s :: Size) where
- class SingSize (s :: Size) where
- withSingSize :: forall (s :: Size) r. SSize s -> (SingSize s => r) -> r
- ssizeToSize :: forall (s :: Size). SSize s -> Size
- class Sized a where
- type family NextSize (s :: Size) = (t :: Size) where ...
- type family PrevSize (s :: Size) = (t :: Size) where ...
- _B :: Prism' Size ()
- _K :: Prism' Size ()
- _M :: Prism' Size ()
- _G :: Prism' Size ()
- _T :: Prism' Size ()
- _P :: Prism' Size ()
- _E :: Prism' Size ()
- _Z :: Prism' Size ()
- _Y :: Prism' Size ()
Size Tags
Byte units.
Since: 0.1
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
data SSize (s :: Size) where Source #
Singleton for Size
.
Since: 0.1
SB :: SSize 'B | Since: 0.1 |
SK :: SSize 'K | Since: 0.1 |
SM :: SSize 'M | Since: 0.1 |
SG :: SSize 'G | Since: 0.1 |
ST :: SSize 'T | Since: 0.1 |
SP :: SSize 'P | Since: 0.1 |
SE :: SSize 'E | Since: 0.1 |
SZ :: SSize 'Z | Since: 0.1 |
SY :: SSize 'Y | Since: 0.1 |
Instances
TestEquality SSize Source # | Since: 0.1 |
Defined in Data.Bytes.Size | |
NFData (SSize s) Source # | Since: 0.1 |
Defined in Data.Bytes.Size | |
Show (SSize s) Source # | Since: 0.1 |
class SingSize (s :: Size) where Source #
Typeclass for recovering the Size
at runtime.
Since: 0.1
withSingSize :: forall (s :: Size) r. SSize s -> (SingSize s => r) -> r Source #
Singleton "with"-style convenience function. Allows us to run a
computation SingSize d => r
without explicitly pattern-matching
every time.
Since: 0.1
Sized Types
Types that have a size.
Since: 0.1
Retrieves the size.
Examples
>>>
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
>>>
import Data.Bytes (Bytes (..))
>>>
hideSize (MkBytes @G 7)
MkSomeSize SG (MkBytes 7)
Instances
Sized (SomeSize n) Source # | Since: 0.1 | ||||
Sized (SomeNet n) Source # | Since: 0.1 | ||||
SingSize s => Sized (Bytes s n) Source # | Since: 0.1 | ||||
SingSize s => Sized (SomeNetDir s n) Source # | Since: 0.1 | ||||
Defined in Data.Bytes.Network.Internal
sizeOf :: SomeNetDir s n -> Size Source # hideSize :: SomeNetDir s n -> HideSize (SomeNetDir s n) Source # | |||||
Sized (SomeNetSize d n) Source # | Since: 0.1 | ||||
Defined in Data.Bytes.Network.Internal
sizeOf :: SomeNetSize d n -> Size Source # hideSize :: SomeNetSize d n -> HideSize (SomeNetSize d n) Source # | |||||
SingSize s => Sized (NetBytes d s n) Source # | Since: 0.1 | ||||
Type Families for Relating Tags
type family NextSize (s :: Size) = (t :: Size) where ... Source #
Type family that relates units to the next larger one.
Examples
>>>
:kind! NextSize 'M
NextSize 'M :: Size = G
>>>
:kind! NextSize 'Y
NextSize 'Y :: Size = (TypeError ...)
Since: 0.1
type family PrevSize (s :: Size) = (t :: Size) where ... Source #
Type family that relates units to the previous smaller one.
Examples
>>>
:kind! PrevSize 'M
PrevSize 'M :: Size = K
>>>
:kind! PrevSize 'B
PrevSize 'B :: Size = (TypeError ...)
Since: 0.1