Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- newtype WithEncoded (fld :: Symbol) a = WithEncoded a
- newtype With (fld :: Symbol) a = With a
- class FromWith f where
- fromWith :: f a -> a

- fromWith2 :: (FromWith f, FromWith g) => f (g a) -> a
- fromWith3 :: (FromWith f, FromWith g, FromWith h) => f (g (h a)) -> a
- fromWith4 :: (FromWith f, FromWith g, FromWith h, FromWith k) => f (g (h (k a))) -> a
- fromWith5 :: (FromWith f, FromWith g, FromWith h, FromWith k, FromWith p) => f (g (h (k (p a)))) -> a
- fromWith6 :: (FromWith f, FromWith g, FromWith h, FromWith k, FromWith p, FromWith q) => f (g (h (k (p (q a))))) -> a

# Documentation

newtype WithEncoded (fld :: Symbol) a Source #

Represents a JSON value of type `a`

that is encoded as a string in a field `fld`

## Instances

newtype With (fld :: Symbol) a Source #

Represents a JSON value of type `a`

in a field `fld`

With a |

## Instances

FromWith (With x) Source # | |

Defined in Antiope.Messages.Types | |

Eq a => Eq (With fld a) Source # | |

Ord a => Ord (With fld a) Source # | |

Show a => Show (With fld a) Source # | |

Generic (With fld a) Source # | |

(KnownSymbol fld, ToJSON a) => ToJSON (With fld a) Source # | |

Defined in Antiope.Messages.Types | |

(KnownSymbol fld, FromJSON a) => FromJSON (With fld a) Source # | |

type Rep (With fld a) Source # | |

Defined in Antiope.Messages.Types |

class FromWith f where Source #

Extracts value from `With`

and `WithEncoded`

wrappers

Will probably be deprecated soon, try using `coerce`

instead.

:: f a | |

-> a | Extracts value from |

## Instances

FromWith (With x) Source # | |

Defined in Antiope.Messages.Types | |

FromWith (WithEncoded x) Source # | |

Defined in Antiope.Messages.Types fromWith :: WithEncoded x a -> a Source # |

fromWith2 :: (FromWith f, FromWith g) => f (g a) -> a Source #

Extracts a value from any combination of two `With`

and/or `WithEncoded`

fromWith2 @(With "one" (WithEncoded "two" True)) == True

fromWith3 :: (FromWith f, FromWith g, FromWith h) => f (g (h a)) -> a Source #

Extracts a value from any combination of two `With`

and/or `WithEncoded`

fromWith3 @(With "one" (WithEncoded "two" (With "three" True))) == True