@@ -4,12 +4,19 @@ Servant allows you to talk about the exceptions you throw in your API
4types. This is not limited to actual exceptions, you can write
4types. This is not limited to actual exceptions, you can write
5handlers that respond with arbitrary open unions of types.
5handlers that respond with arbitrary open unions of types.
9+:warning: This cookbook is compatible with GHC 8.6.1 or higher :warning:
7## Preliminaries
11## Preliminaries
10{-# LANGUAGE ConstraintKinds #-}
14{-# LANGUAGE ConstraintKinds #-}
11{-# LANGUAGE DataKinds #-}
15{-# LANGUAGE DataKinds #-}
12{-# LANGUAGE DeriveGeneric #-}
16{-# LANGUAGE DeriveGeneric #-}
17+{-# LANGUAGE DerivingStrategies #-}
18+{-# LANGUAGE DeriveAnyClass #-}
19+{-# LANGUAGE DerivingVia #-}
13{-# LANGUAGE FlexibleContexts #-}
20{-# LANGUAGE FlexibleContexts #-}
14{-# LANGUAGE FlexibleInstances #-}
21{-# LANGUAGE FlexibleInstances #-}
15{-# LANGUAGE GeneralizedNewtypeDeriving #-}
22{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -154,12 +161,8 @@ Example usage:
155```haskell
162```haskell
156data Foo = Foo Int Int Int
163data Foo = Foo Int Int Int
157− deriving (Show, Eq, GHC.Generic)
164+ deriving (Show, Eq, GHC.Generic, ToJSON)
158−
165+ deriving HasStatus via WithStatus 200 Foo
161−instance HasStatus Foo where
162− type StatusOf Foo = 200
164data Bar = Bar
167data Bar = Bar
165 deriving (Show, Eq, GHC.Generic)
168 deriving (Show, Eq, GHC.Generic)