effects

所属分类:自然语言处理
开发工具:Haskell
文件大小:16KB
下载次数:0
上传日期:2022-01-17 03:31:10
上 传 者sh-1993
说明:  简要探讨在纯函数式编程语言中建模副作用的各种方法。
(A brief exploration of the various approaches to modeling side effects in a purely functional programming language.)

文件列表:
CODE_OF_CONDUCT.md (3488, 2022-01-17)
CONTRIBUTING.md (331, 2022-01-17)
LICENSE.md (1064, 2022-01-17)
MAINTAINERS.md (545, 2022-01-17)
app (0, 2022-01-17)
app\Main.hs (577, 2022-01-17)
package.yaml (923, 2022-01-17)
scripts (0, 2022-01-17)
scripts\lint-general.rb (1472, 2022-01-17)
src (0, 2022-01-17)
src\BespokeMonad.hs (2212, 2022-01-17)
src\ExtensibleEffects.hs (2507, 2022-01-17)
src\FreeMonad.hs (1692, 2022-01-17)
src\MonadTransformers.hs (1623, 2022-01-17)
stack.yaml (75, 2022-01-17)
stack.yaml.lock (741, 2022-01-17)
test (0, 2022-01-17)
test\BespokeMonadSpec.hs (318, 2022-01-17)
test\ExpectedOutput.hs (133, 2022-01-17)
test\ExtensibleEffectsSpec.hs (333, 2022-01-17)
test\FreeMonadSpec.hs (309, 2022-01-17)
test\MonadTransformersSpec.hs (333, 2022-01-17)
test\Spec.hs (315, 2022-01-17)
toast.yml (4845, 2022-01-17)

# Effects A brief exploration of the various approaches to modeling side effects in a purely functional programming language. [![Build status](https://github.com/stepchowfun/effects/workflows/Continuous%20integration/badge.svg?branch=master)](https://github.com/stepchowfun/effects/actions?query=branch%3Amaster) ## The challenge Write a program that initializes an accumulator and random seed both with `0` and then runs the following procedure 10 times: - Log the value of the accumulator. - Pick an integer uniformly randomly from the half-open interval `[0, 10)`. - Mutate the accumulator by adding the random integer to it. Thus, 3 computational effects are exhibited: logging, randomness, and mutable state. ## Techniques demonstrated This repository contains 4 implementations of the program described above, each demonstrating a specific technique: - A [bespoke monad](https://github.com/stepchowfun/effects/blob/master/src/BespokeMonad.hs) - A standard [monad transformer stack](https://github.com/stepchowfun/effects/blob/master/src/MonadTransformers.hs) - A [free monad](https://github.com/stepchowfun/effects/blob/master/src/FreeMonad.hs) - The [`Eff` monad](https://github.com/stepchowfun/effects/blob/master/src/ExtensibleEffects.hs) from the "extensible effects" framework ## Instructions Make sure you have [Toast](https://github.com/stepchowfun/toast) installed. Then you can run `toast run` to build and run the demo.

近期下载者

相关文件


收藏者