git.iko.soy/typeable/servant
on master help sign in
Merge pull request #1407 from akhesaCaro/using_derivingvia_uverb
bc61447Caroline GAUDREAU
doc/cookbook/uverb/UVerb.lhs+9−6
@@ -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.
6
6
7+## Compatibility
8+
9+:warning: This cookbook is compatible with GHC 8.6.1 or higher :warning:
10+
7## Preliminaries
11## Preliminaries
8
12
9```haskell
13```haskell
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:
154
161
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
159−instance ToJSON Foo
160−
161−instance HasStatus Foo where
162− type StatusOf Foo = 200
163
166
164data Bar = Bar
167data Bar = Bar
165 deriving (Show, Eq, GHC.Generic)
168 deriving (Show, Eq, GHC.Generic)
doc/cookbook/uverb/uverb.cabal+3−1
@@ -28,6 +28,8 @@ executable cookbook-uverb
28 , swagger2
28 , swagger2
29 , wai
29 , wai
30 , warp
30 , warp
31+ if impl(ghc < 8.6.1)
32+ buildable: False
31− default-language: Haskell2010
33+ default-language: Haskell2010
32 ghc-options: -Wall -pgmL markdown-unlit
34 ghc-options: -Wall -pgmL markdown-unlit
33 build-tool-depends: markdown-unlit:markdown-unlit
35 build-tool-depends: markdown-unlit:markdown-unlit