named

Named parameters (keyword arguments) for Haskell

https://github.com/monadfix/named

Version on this page:0.3.0.1@rev:2
LTS Haskell 22.14:0.3.0.1@rev:5
Stackage Nightly 2024-03-28:0.3.0.1@rev:5
Latest on Hackage:0.3.0.1@rev:5

See all snapshots named appears in

BSD-3-Clause licensed by Vladislav Zavialov
Maintained by Monadfix
This version can be pinned in stack with:named-0.3.0.1@sha256:418543272f0c844a77639b05276ee3906d5f305cd4cab46fafcb4f15b7f1e60d,2312

Module documentation for 0.3.0.1

Depends on 1 package(full list with versions):

named is a lightweight library for named function parameters (keyword arguments) based on overloaded labels. Keyword arguments have several advantages over positional arguments:

  • they can be supplied in arbitrary order

  • their names serve as documentation at call site

  • it is impossible to accidentally mix them up

Unlike newtype wrappers, keyword arguments don't pollute the global namespace, don't require top-level definitions, and don't need to be exported.

This implementation of named parameters is typesafe, provides good type inference, descriptive type errors, and has no runtime overhead.

Example usage:

import Named

createSymLink :: "from" :! FilePath -> "to" :! FilePath -> IO ()
createSymLink (Arg from) (Arg to) = ...

main = createSymLink ! #from "/path/to/source"
                     ! #to "/target/path"

Changes

0.3.0.1

  • Bumped upper bounds for GHC 8.8.

0.3.0.0

  • Added ‘param’, ‘paramF’.
  • Export ‘NamedF(Arg, ArgF)’ as a bundle.

0.2.0.0

  • Removed ‘Flag’, ‘named’, ‘Apply’, ‘apply’.
  • Changed notation: ‘Named’ is now ‘(:!)’ in types, ‘Arg’ in patterns.
  • Added ‘arg’, ‘argF’.
  • Support for optional parameters: see ‘argDef’, ‘defaults’, ‘(:?)’.
  • ‘with #param value’ is now ‘with (#param value)’ to allow ‘with defaults’.
  • Internals are now exposed from “Named.Internal”.

0.1.0.0

  • First version. Released on an unsuspecting world.