MyNixOS website logo
Description

Automatically generate Servant API modules.

servant-serf

servant-serf is a preprocessor for GHC that automatically generates Servant API modules. It is similar to the hspec-discover package.

Example input

{-# OPTIONS_GHC -F -pgmF servant-serf #-}

Example output

{-# LINE 1 "Example.hs" #-}
{-# OPTIONS_GHC -w #-}

module Example where

import qualified Servant

import qualified Example.One
import qualified Example.Two

type API
  = Example.One.API
  Servant.:<|> Example.Two.API

server
  = Example.One.server
  Servant.:<|> Example.Two.server

Options

To pass options into servant-serf, use -optF. For example:

{-# OPTIONS_GHC -F -pgmF servant-serf -optF --depth=shallow #-}
  • --module-name=STRING: Sets the name to use for the generated module. By default this is determined from the source file path. For example src/X.hs would use the module name X.

  • --depth=deep|shallow: Controls whether to search through only one dierctory (shallow) or recursively (deep). Defaults to deep.

  • --api-name=STRING: Sets the name to use for the API type. Defaults to API. Note that the same name is used for both referenced API types and the generated API type.

  • --server-name=STRING: Sets the name to use for the server value. Defaults to server. Note that the same name is used for both referenced server values and the generated server value.

Notes

  • The input module is completely ignored.

  • Modules are sorted by name. There is no way to customize how they are sorted.

  • All modules below the current module are included. There is no way to customize which modules are included or excluded.

  • The generated server value does not have a type signature. It should have type Servant.ServerT API m for some m, but that m can change and is easily inferred by GHC.

Metadata

Version

0.3.1.6

License

Executables (1)

  • bin/servant-serf

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows