MyNixOS website logo
Description

Plugin and base library to support supermonads in Haskell.

The supermonad library adds support for supermonads to GHC using a type checker plugin. Plugins are available from GHC 7.10 onwards. The base library containing the Haskell representation of super monads is also given by this package. Supermonads provide a unified representation of several monadic generalizations to remove the need for manual disambiguation between these notions and allow sharing of common functions between them. Additional information can be found in the README.

Supermonads and superapplicatives for GHC

Implementation of supermonads for GHC. See the Supermonads: One Notion to Bind Them All paper for detailed explanation of version 0.1. An updated version of the paper that also explains superapplicatives has been submitted to JFP.

Supermonads

The library offers two definitions for supermonads. The version in Control.Super.Monad does not have support for constrained monads. The version in Control.Super.Monad.Constrained has support for constrained monads. The different versions are provided, because working with the additional constraints required for constrained monads can be cumbersome sometimes. We want to offer people a possibility to experiment with supermonads without having to bother with these constraints, if they don't need constrained monads. If you have any feedback or suggestions for improvement from you usage of supermonads, please leave them on the GitHub bug tracker or write an email to the maintainer. These parallel structures will not be maintained indefinitely and at some point we will probably only offer supermonads with support for constrained monads.

Superapplicatives

Support for generalized applicatives was added in version 0.2. For users this does not change anything.

Build Status

masterdev
build status masterbuild status dev

GHC Version

The implementation has been tested with GHC in version 7.10.3, 8.0.2 and 8.2.1.

Versions of GHC prior to version 7.10.1 will most certainly not work, because the plugin mechanism was still in development.

Newer version of GHC may work. If you encounter problems with a newer version of GHC, please file a bug report so it can be fixed.

Usage

To use supermonads in a module you need to do the following:

  • Enable RebindableSyntax in your module by using the LANGUAGE pragma:

    {-# LANGUAGE RebindableSyntax #-}

  • Enable the plugin in that modules using the the OPTIONS_GHC pragma:

    {-# OPTIONS_GHC -fplugin Control.Super.Monad.Plugin #-}

  • Import the supermonad prelude Control.Super.Monad.Prelude. If you choose to work with constrained monads you will need to import Control.Super.Monad.Constrained.Prelude instead.

  • Make sure to compile the module with the -dynamic flag. This is required for GHC's plugin mechanism to work properly.

Bug Reports

If you file a bug report, please always include the version of GHC you are working with and a minimal example that shows the problem.

Examples

Examples for the use of the plugin with different kinds of monad generalizations are provided in the examples directory. All examples have their own separate cabal file and offer a version of the code with and without the use of supermonads.

A minimal example of how to use supermonads can be found under examples/monad/minimal. It is a good entry point to play around with supermonads.

Metadata

Version

0.2.1.1

Platforms (75)

    Darwin
    FreeBSD
    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-freebsd
  • 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-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows