Merge pull request #1407 from akhesaCaro/using_derivingvia_uverb

Using DerivingVia in UVerb's cookbook
This commit is contained in:
Caroline GAUDREAU 2021-04-09 16:43:12 +02:00 committed by GitHub
commit bc6144716b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -4,12 +4,19 @@ Servant allows you to talk about the exceptions you throw in your API
types. This is not limited to actual exceptions, you can write
handlers that respond with arbitrary open unions of types.
## Compatibility
:warning: This cookbook is compatible with GHC 8.6.1 or higher :warning:
## Preliminaries
```haskell
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@ -154,12 +161,8 @@ Example usage:
```haskell
data Foo = Foo Int Int Int
deriving (Show, Eq, GHC.Generic)
instance ToJSON Foo
instance HasStatus Foo where
type StatusOf Foo = 200
deriving (Show, Eq, GHC.Generic, ToJSON)
deriving HasStatus via WithStatus 200 Foo
data Bar = Bar
deriving (Show, Eq, GHC.Generic)

View File

@ -28,6 +28,8 @@ executable cookbook-uverb
, swagger2
, wai
, warp
default-language: Haskell2010
if impl(ghc < 8.6.1)
buildable: False
default-language: Haskell2010
ghc-options: -Wall -pgmL markdown-unlit
build-tool-depends: markdown-unlit:markdown-unlit