Merge pull request #1407 from akhesaCaro/using_derivingvia_uverb
Using DerivingVia in UVerb's cookbook
This commit is contained in:
commit
bc6144716b
2 changed files with 12 additions and 7 deletions
|
@ -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
|
types. This is not limited to actual exceptions, you can write
|
||||||
handlers that respond with arbitrary open unions of types.
|
handlers that respond with arbitrary open unions of types.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
:warning: This cookbook is compatible with GHC 8.6.1 or higher :warning:
|
||||||
|
|
||||||
## Preliminaries
|
## Preliminaries
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
{-# LANGUAGE ConstraintKinds #-}
|
{-# LANGUAGE ConstraintKinds #-}
|
||||||
{-# LANGUAGE DataKinds #-}
|
{-# LANGUAGE DataKinds #-}
|
||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
|
{-# LANGUAGE DerivingVia #-}
|
||||||
{-# LANGUAGE FlexibleContexts #-}
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
|
@ -154,12 +161,8 @@ Example usage:
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
data Foo = Foo Int Int Int
|
data Foo = Foo Int Int Int
|
||||||
deriving (Show, Eq, GHC.Generic)
|
deriving (Show, Eq, GHC.Generic, ToJSON)
|
||||||
|
deriving HasStatus via WithStatus 200 Foo
|
||||||
instance ToJSON Foo
|
|
||||||
|
|
||||||
instance HasStatus Foo where
|
|
||||||
type StatusOf Foo = 200
|
|
||||||
|
|
||||||
data Bar = Bar
|
data Bar = Bar
|
||||||
deriving (Show, Eq, GHC.Generic)
|
deriving (Show, Eq, GHC.Generic)
|
||||||
|
|
|
@ -28,6 +28,8 @@ executable cookbook-uverb
|
||||||
, swagger2
|
, swagger2
|
||||||
, wai
|
, wai
|
||||||
, warp
|
, warp
|
||||||
default-language: Haskell2010
|
if impl(ghc < 8.6.1)
|
||||||
|
buildable: False
|
||||||
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall -pgmL markdown-unlit
|
ghc-options: -Wall -pgmL markdown-unlit
|
||||||
build-tool-depends: markdown-unlit:markdown-unlit
|
build-tool-depends: markdown-unlit:markdown-unlit
|
||||||
|
|
Loading…
Reference in a new issue