Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides the Direction
type and singletons.
Since: 0.1
Synopsis
- data Direction
- data SDirection (d :: Direction) where
- SDown :: SDirection 'Down
- SUp :: SDirection 'Up
- class SingDirection (d :: Direction) where
- singDirection :: SDirection d
- class Directed a where
- type HideDirection a
- directionOf :: a -> Direction
- hideDirection :: a -> HideDirection a
- withSingDirection :: forall (d :: Direction) r. SDirection d -> (SingDirection d => r) -> r
- sdirectionToDirection :: forall (d :: Direction). SDirection d -> Direction
- _Down :: Prism' Direction ()
- _Up :: Prism' Direction ()
Direction Tags
Tags for differentiating downloaded vs. uploaded bytes.
Since: 0.1
Instances
NFData Direction Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction | |
Generic Direction Source # | |
Defined in Data.Bytes.Network.Direction | |
Show Direction Source # | Since: 0.1 |
Eq Direction Source # | Since: 0.1 |
Hashable Direction Source # | Since: 0.1 |
Parser Direction Source # | Since: 0.1 |
TestEquality SDirection Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction testEquality :: forall (a :: Direction) (b :: Direction). SDirection a -> SDirection b -> Maybe (a :~: b) # | |
type Rep Direction Source # | Since: 0.1 |
data SDirection (d :: Direction) where Source #
Singleton for Direction
.
Since: 0.1
SDown :: SDirection 'Down | Since: 0.1 |
SUp :: SDirection 'Up | Since: 0.1 |
Instances
TestEquality SDirection Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction testEquality :: forall (a :: Direction) (b :: Direction). SDirection a -> SDirection b -> Maybe (a :~: b) # | |
NFData (SDirection d) Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction rnf :: SDirection d -> () # | |
Show (SDirection d) Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction showsPrec :: Int -> SDirection d -> ShowS # show :: SDirection d -> String # showList :: [SDirection d] -> ShowS # |
class SingDirection (d :: Direction) where Source #
Typeclass for recovering the Direction
at runtime.
Since: 0.1
singDirection :: SDirection d Source #
Since: 0.1
Instances
SingDirection 'Down Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction | |
SingDirection 'Up Source # | Since: 0.1 |
Defined in Data.Bytes.Network.Direction singDirection :: SDirection 'Up Source # |
class Directed a where Source #
Types that have a direction.
Since: 0.1
type HideDirection a Source #
Type used to hide the size.
Since: 0.1
directionOf :: a -> Direction Source #
Retrieve the direction.
Examples
>>>
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
>>>
import Data.Bytes.Network (NetBytes (..), Size (..))
>>>
hideDirection (MkNetBytesP @Up @G 7)
MkSomeNetDir SUp (MkNetBytes (MkBytes 7))
Since: 0.1
Instances
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