Skip to content

Commit bc61447

Browse files
authored
Merge pull request #1407 from akhesaCaro/using_derivingvia_uverb
Using DerivingVia in UVerb's cookbook
2 parents d06b65c + f30b72c commit bc61447

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/cookbook/uverb/UVerb.lhs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ Servant allows you to talk about the exceptions you throw in your API
44
types. This is not limited to actual exceptions, you can write
55
handlers that respond with arbitrary open unions of types.
66

7+
## Compatibility
8+
9+
:warning: This cookbook is compatible with GHC 8.6.1 or higher :warning:
10+
711
## Preliminaries
812

913
```haskell
1014
{-# LANGUAGE ConstraintKinds #-}
1115
{-# LANGUAGE DataKinds #-}
1216
{-# LANGUAGE DeriveGeneric #-}
17+
{-# LANGUAGE DerivingStrategies #-}
18+
{-# LANGUAGE DeriveAnyClass #-}
19+
{-# LANGUAGE DerivingVia #-}
1320
{-# LANGUAGE FlexibleContexts #-}
1421
{-# LANGUAGE FlexibleInstances #-}
1522
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -154,12 +161,8 @@ Example usage:
154161
155162
```haskell
156163
data Foo = Foo Int Int Int
157-
deriving (Show, Eq, GHC.Generic)
158-
159-
instance ToJSON Foo
160-
161-
instance HasStatus Foo where
162-
type StatusOf Foo = 200
164+
deriving (Show, Eq, GHC.Generic, ToJSON)
165+
deriving HasStatus via WithStatus 200 Foo
163166
164167
data Bar = Bar
165168
deriving (Show, Eq, GHC.Generic)

doc/cookbook/uverb/uverb.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ executable cookbook-uverb
2828
, swagger2
2929
, wai
3030
, warp
31-
default-language: Haskell2010
31+
if impl(ghc < 8.6.1)
32+
buildable: False
33+
default-language: Haskell2010
3234
ghc-options: -Wall -pgmL markdown-unlit
3335
build-tool-depends: markdown-unlit:markdown-unlit

0 commit comments

Comments
 (0)