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

Data.Bytes.Network.Direction

Description

Provides the Direction type and singletons.

Since: 0.1

Synopsis

Direction Tags

data Direction Source #

Tags for differentiating downloaded vs. uploaded bytes.

Since: 0.1

Constructors

Down

Since: 0.1

Up

Since: 0.1

Instances

Instances details
NFData Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Methods

rnf :: Direction -> () #

Generic Direction Source # 
Instance details

Defined in Data.Bytes.Network.Direction

Associated Types

type Rep Direction

Since: si-bytes-0.1

Instance details

Defined in Data.Bytes.Network.Direction

type Rep Direction = D1 ('MetaData "Direction" "Data.Bytes.Network.Direction" "si-bytes-0.1-inplace" 'False) (C1 ('MetaCons "Down" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Up" 'PrefixI 'False) (U1 :: Type -> Type))
Show Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Eq Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Hashable Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Parser Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

TestEquality SDirection Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Methods

testEquality :: forall (a :: Direction) (b :: Direction). SDirection a -> SDirection b -> Maybe (a :~: b) #

type Rep Direction Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

type Rep Direction = D1 ('MetaData "Direction" "Data.Bytes.Network.Direction" "si-bytes-0.1-inplace" 'False) (C1 ('MetaCons "Down" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Up" 'PrefixI 'False) (U1 :: Type -> Type))

data SDirection (d :: Direction) where Source #

Singleton for Direction.

Since: 0.1

Constructors

SDown :: SDirection 'Down

Since: 0.1

SUp :: SDirection 'Up

Since: 0.1

Instances

Instances details
TestEquality SDirection Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Methods

testEquality :: forall (a :: Direction) (b :: Direction). SDirection a -> SDirection b -> Maybe (a :~: b) #

NFData (SDirection d) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

Methods

rnf :: SDirection d -> () #

Show (SDirection d) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

class SingDirection (d :: Direction) where Source #

Typeclass for recovering the Direction at runtime.

Since: 0.1

Methods

singDirection :: SDirection d Source #

Since: 0.1

Instances

Instances details
SingDirection 'Down Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

SingDirection 'Up Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Direction

class Directed a where Source #

Types that have a direction.

Since: 0.1

Associated Types

type HideDirection a Source #

Type used to hide the size.

Since: 0.1

Methods

directionOf :: a -> Direction Source #

Retrieve the direction.

Examples

Expand
>>> import Data.Bytes.Network
>>> directionOf (MkNetBytesP @Up @G 7)
Up
>>> directionOf (hideSize $ hideDirection $ MkNetBytesP @Down @M 100)
Down

Since: 0.1

hideDirection :: a -> HideDirection a Source #

Hides the direction.

Examples

Expand
>>> import Data.Bytes.Network (NetBytes (..), Size (..))
>>> hideDirection (MkNetBytesP @Up @G 7)
MkSomeNetDir SUp (MkNetBytes (MkBytes 7))

Since: 0.1

Instances

Instances details
Directed (SomeNet n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideDirection (SomeNet n) 
Instance details

Defined in Data.Bytes.Network.Internal

Directed (SomeNetDir s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideDirection (SomeNetDir s n) 
Instance details

Defined in Data.Bytes.Network.Internal

SingDirection d => Directed (SomeNetSize d n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideDirection (SomeNetSize d n) 
Instance details

Defined in Data.Bytes.Network.Internal

SingDirection d => Directed (NetBytes d s n) Source #

Since: 0.1

Instance details

Defined in Data.Bytes.Network.Internal

Associated Types

type HideDirection (NetBytes d s n) 
Instance details

Defined in Data.Bytes.Network.Internal

type HideDirection (NetBytes d s n) = SomeNetDir s n

withSingDirection :: forall (d :: Direction) r. SDirection d -> (SingDirection d => r) -> r Source #

Singleton "with"-style convenience function. Allows us to run a computation SingDirection d => r without explicitly pattern-matching every time.

Since: 0.1

sdirectionToDirection :: forall (d :: Direction). SDirection d -> Direction Source #

Since: 0.1

Optics

_Down :: Prism' Direction () Source #

Since: 0.1

_Up :: Prism' Direction () Source #

Since: 0.1