MyNixOS website logo
Description

Prelude based on protolude for GHC 8 and beyond.

A Prelude relpacement for GHC 8 with a focus on building applications with Lenses, Machines, and Applicatives.

liblawless: An Effectful Foundation

Overview

liblawless is a replacement for the standard Prelude. It targets GHC 8.0 and newer. It's core is building a fine-grained but readily accessible Effect model to move more type checking of code that changes its environment out of plain IO.

Pure vs Effectful Functions

Pure functions don't affect the anything outside of the function. A Pure function will run a calculation on the given values, and return a result. If you pass in the same parameters, you'll always get the same result no matter how many times you call the function.

Effectful functions are functions that do affect the program outside the function, and often the environment outside the computer running them. Even with the same parameters, Effectful Functions can return different results. In many cases they can even return signals that completing their task wasn't possible. In many languages these are called "Side Effects", and aren't modeled in the type system at all. Haskell comes with a simple Effect model in its type system, the [io][IO monad].

Kinds of Effects

The [io][IO monad] models Effects a function has on the world outside the program. There are other, more limited Effects as well, and there are libraries for managing these as well. The two most common are:

  • [transformers][Transformers]
  • [mtl][The MTL]

[transformers]: http://hackage.haskell.org/package/transformers Transformers [mtl]: http://hackage.haskell.org/package/mtl

These model Effects that only apply to the current program, while the IO monad models ''all other effects'' on the world. That's a really broad brush. Most bugs in Haskell code are in the IO monad.

This project is implementing several extra types of Effects that affect the world. Instead of treating them all the same, though, it breaks them up into much smaller kinds of Effects. For example, for accessing files, it's possible to:

  • read bytes from a file
  • write bytes to a file
  • read lines of text from a file
  • write lines of text from a file
  • read arbitrary data from a file, operate on these data items, and write them to a network stream
  • many other simple and complex operations

We are building them on top of the machines library. This library offers a composable model for connecting strongly-typed streams together. It also implements provisions for arbitrary effects, and connecting Effectful functions with Pure functions into streams of computations. When combined with the async library, these streams, and even individual nodes in these streams, can be run concurrently and safely, making full use of multicore systems.

Metadata

Version

0.26.0

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