freer-effects: Implementation of effect system for Haskell.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Implementation of effect system for Haskell, which is based on the work of Oleg Kiselyov et al.:

The key features are:


[Skip to Readme]

Properties

Versions 0.3.0.0, 0.3.0.0, 0.3.0.1
Change log changelog.md
Dependencies base (>=4.7 && <5), freer-effects [details]
License BSD-3-Clause
Copyright (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.
Author Allele Dev, Ixcom Core Team, and other contributors
Maintainer ixcom-core@ixperta.com
Category Control
Home page https://github.com/IxpertaSolutions/freer-effects
Bug tracker https://github.com/IxpertaSolutions/freer-effects/issues
Source repo head: git clone https://github.com/IxpertaSolutions/freer-effects.git -b master
this: git clone https://github.com/IxpertaSolutions/freer-effects.git(tag 0.3.0.0)
Uploaded by PeterTrsko at 2017-03-06T00:08:23Z

Modules

[Index]

Flags

Manual Flags

NameDescriptionDefault
pedantic

Pass additional warning flags and -Werror to GHC.

Disabled
test-hlint

Enable test suite that checks sources using HLint.

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for freer-effects-0.3.0.0

[back to package description]

Freer Effects: Extensible Effects with Freer Monads

Haskell Programming Language BSD3 License

Hackage Hackage Dependencies Build

Description

Library freer-effects is an implementation of effect system for Haskell, which is based on the work of Oleg Kiselyov et al.:

Much of the implementation is a repackaging and cleaning up of the reference materials provided here.

Features

The key features of Freer are:

Example: Console DSL

Here's what using Freer looks like:

{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
module Console where

import Control.Monad.Freer
import Control.Monad.Freer.Internal
import System.Exit hiding (ExitSuccess)

--------------------------------------------------------------------------------
                               -- Effect Model --
--------------------------------------------------------------------------------
data Console s where
    PutStrLn    :: String -> Console ()
    GetLine     :: Console String
    ExitSuccess :: Console ()

putStrLn' :: Member Console r => String -> Eff r ()
putStrLn' = send . PutStrLn

getLine' :: Member Console r => Eff r String
getLine' = send GetLine

exitSuccess' :: Member Console r => Eff r ()
exitSuccess' = send ExitSuccess

--------------------------------------------------------------------------------
                          -- Effectful Interpreter --
--------------------------------------------------------------------------------
runConsole :: Eff '[Console] w -> IO w
runConsole (Val x) = return x
runConsole (E u q) =
    case extract u of
        PutStrLn msg -> putStrLn msg >>  runConsole (qApp q ())
        GetLine      -> getLine      >>= \s -> runConsole (qApp q s)
        ExitSuccess  -> exitSuccess

--------------------------------------------------------------------------------
                             -- Pure Interpreter --
--------------------------------------------------------------------------------
runConsolePure :: [String] -> Eff '[Console] w -> [String]
runConsolePure inputs req =
    reverse . snd $ run (handleRelayS (inputs, []) (\s _ -> pure s) go req)
  where
    go  :: ([String], [String])
        -> Console v
        -> (([String], [String]) -> Arr '[] v ([String], [String]))
        -> Eff '[] ([String], [String])
    go (is,   os) (PutStrLn msg) q = q (is, msg : os) ()
    go (i:is, os) GetLine        q = q (is, os) i
    go ([],   _ ) GetLine        _ = error "Not enough lines"
    go (_,    os) ExitSuccess    _ = pure ([], os)

Contributing

Contributions are welcome! Documentation, examples, code, and feedback - they all help.

Developer Setup

The easiest way to start contributing is to install stack. Stack can install GHC/Haskell for you, and automates common developer tasks.

The key commands are:

For more information about stack tool can be found in its documentation.

Licensing

This project is distrubted under a BSD3 license. See the included LICENSE file for more details.

Acknowledgements

Package freer-effects started as a fork of freer authored by Allele Dev.

This package would not be possible without the paper and the reference implementation. In particular:

There will be deviations from the source.