Hackage.Security.Client.Formats

hackage-security-0.5.2.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 :: * -> * where
  - FUn :: Format FormatUn
  - FGz :: Format FormatGz
- data Formats :: * -> * -> * where
  - FsNone :: Formats () a
  - FsUn :: a -> Formats (FormatUn :- ()) a
  - FsGz :: a -> Formats (FormatGz :- ()) a
  - FsUnGz :: a -> a -> Formats (FormatUn :- (FormatGz :- ())) a
- data HasFormat :: * -> * -> * where
  - HFZ :: Format f -> HasFormat (f :- fs) f
  - HFS :: HasFormat fs f -> HasFormat (f' :- fs) f
- 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 #

data FormatGz #

## Term level

data Format :: * -> * where #

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

Eq (Format f) # |
Methods (==) :: Format f -> Format f -> Bool # (/=) :: Format f -> Format f -> Bool #
Show (Format f) # |
Methods showsPrec :: Int -> Format f -> ShowS # show :: Format f -> String # showList :: [Format f] -> ShowS #

data Formats :: * -> * -> * where #

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 unexpect 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 :: Formats () a |
FsUn :: a -> Formats (FormatUn :- ()) a |
FsGz :: a -> Formats (FormatGz :- ()) a |
FsUnGz :: a -> a -> Formats (FormatUn :- (FormatGz :- ())) a |

Instances

Functor (Formats fs) # |
Methods fmap :: (a -> b) -> Formats fs a -> Formats fs b # (<$) :: a -> Formats fs b -> Formats fs a #
Eq a => Eq (Formats fs a) # |
Methods (==) :: Formats fs a -> Formats fs a -> Bool # (/=) :: Formats fs a -> Formats fs a -> Bool #
Show a => Show (Formats fs a) # |
Methods showsPrec :: Int -> Formats fs a -> ShowS # show :: Formats fs a -> String # showList :: [Formats fs a] -> ShowS #

# Key membership

data HasFormat :: * -> * -> * where #

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

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

Constructors

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

Instances

Eq (HasFormat fs f) # |
Methods (==) :: HasFormat fs f -> HasFormat fs f -> Bool # (/=) :: HasFormat fs f -> HasFormat fs f -> Bool #
Show (HasFormat fs f) # |
Methods showsPrec :: Int -> HasFormat fs f -> ShowS # show :: HasFormat fs f -> String # showList :: [HasFormat fs f] -> ShowS #

## Utility

hasFormatAbsurd :: HasFormat () f -> a #

hasFormatGet :: HasFormat fs f -> Format f #

# Map-like operations

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 #