git.iko.soy/typeable/servant
on master help sign in
Merge pull request #1407 from akhesaCaro/using_derivingvia_uverb

Using DerivingVia in UVerb's cookbook

commitbc6144716b186be0c78264bcc195bd9266d12d98 authorCaroline GAUDREAU <caroline.gaudreau@gmail.com> dateFri 9 Apr 2021, 16:43 (6 years ago) parentd06b65cf30b72c
2 files changed+12−7
doc/cookbook/uverb/UVerb.lhs+9−6 doc/cookbook/uverb/uverb.cabal+3−1
doc/cookbook/uverb/UVerb.lhs+9−6
@@ -4,12 +4,19 @@ Servant allows you to talk about the exceptions you throw in your API
44types. This is not limited to actual exceptions, you can write
55handlers 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
156163data 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
164167data Bar = Bar
165168 deriving (Show, Eq, GHC.Generic)
doc/cookbook/uverb/uverb.cabal+3−1
@@ -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