hackage-security-0.6.3.2: Hackage security library

Safe Haskell | None
Language | Haskell2010

Hackage.Security.Client.Formats

Contents

- Formats
  - Type level
  - Term level
- Key membership
  - Utility
- Map-like operations

Synopsis

- data FormatUn
- data FormatGz
- data Format a where
  - FUn :: Format FormatUn
  - FGz :: Format FormatGz
- data Formats a b where
  - FsNone :: forall b. Formats () b
  - FsUn :: forall b. b -> Formats (FormatUn :- ()) b
  - FsGz :: forall b. b -> Formats (FormatGz :- ()) b
  - FsUnGz :: forall b. b -> b -> Formats (FormatUn :- (FormatGz :- ())) b
- data HasFormat a b where
  - HFZ :: forall b fs. Format b -> HasFormat (b :- fs) b
  - HFS :: forall fs b f'. HasFormat fs b -> HasFormat (f' :- fs) b
- hasFormatAbsurd :: HasFormat () f -> a
- hasFormatGet :: HasFormat fs f -> Format f
- formatsMap :: (forall f. Format f -> a -> b) -> Formats fs a -> Formats fs b
- formatsMember :: Format f -> Formats fs a -> Maybe (HasFormat fs f)
- formatsLookup :: HasFormat fs f -> Formats fs a -> a

# Formats

## Type level

data FormatUn Source #

data FormatGz Source #

## Term level

data Format a where Source #

Format is a singleton type (reflection type to term level)

NOTE: In the future we might add further compression formats.

Constructors

FUn :: Format FormatUn |
FGz :: Format FormatGz |

#### Instances

Instances details

Show (Format f) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods showsPrec :: Int -> Format f -> ShowS Source # show :: Format f -> String Source # showList :: [Format f] -> ShowS Source #
Eq (Format f) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods (==) :: Format f -> Format f -> Bool Source # (/=) :: Format f -> Format f -> Bool Source #

data Formats a b where Source #

Available formats

Rather than having a general list here, we enumerate all possibilities. This means we are very precise about what we expect, and we avoid any runtime errors about unexpected format definitions.

NOTE: If we add additional cases here (for dealing with additional formats) all calls to `error "inaccessible"` need to be reevaluated.

Constructors

FsNone :: forall b. Formats () b |
FsUn :: forall b. b -> Formats (FormatUn :- ()) b |
FsGz :: forall b. b -> Formats (FormatGz :- ()) b |
FsUnGz :: forall b. b -> b -> Formats (FormatUn :- (FormatGz :- ())) b |

#### Instances

Instances details

Functor (Formats fs) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods fmap :: (a -> b) -> Formats fs a -> Formats fs b Source # (<$) :: a -> Formats fs b -> Formats fs a Source #
Show a => Show (Formats fs a) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods showsPrec :: Int -> Formats fs a -> ShowS Source # show :: Formats fs a -> String Source # showList :: [Formats fs a] -> ShowS Source #
Eq a => Eq (Formats fs a) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods (==) :: Formats fs a -> Formats fs a -> Bool Source # (/=) :: Formats fs a -> Formats fs a -> Bool Source #

# Key membership

data HasFormat a b where Source #

`HasFormat fs f` is a proof that `f` is a key in `fs`.

See `formatsMember` and `formatsLookup` for typical usage.

Constructors

HFZ :: forall b fs. Format b -> HasFormat (b :- fs) b |
HFS :: forall fs b f'. HasFormat fs b -> HasFormat (f' :- fs) b |

#### Instances

Instances details

Show (HasFormat fs f) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods showsPrec :: Int -> HasFormat fs f -> ShowS Source # show :: HasFormat fs f -> String Source # showList :: [HasFormat fs f] -> ShowS Source #
Eq (HasFormat fs f) Source # |
Instance details Defined in Hackage.Security.Client.Formats Methods (==) :: HasFormat fs f -> HasFormat fs f -> Bool Source # (/=) :: HasFormat fs f -> HasFormat fs f -> Bool Source #

## Utility

hasFormatAbsurd :: HasFormat () f -> a Source #

hasFormatGet :: HasFormat fs f -> Format f Source #

# Map-like operations

formatsMap :: (forall f. Format f -> a -> b) -> Formats fs a -> Formats fs b Source #

formatsMember :: Format f -> Formats fs a -> Maybe (HasFormat fs f) Source #

formatsLookup :: HasFormat fs f -> Formats fs a -> a Source #