So you're in posix sh and you want to do the equivalent of this in bash:
foo | tee >(bar) >(baz) >/dev/null(Suppose that bar and baz don't produce output. Add redirections where
needed if that's not the case.)
In Haskell we can define Monoid instances like this:
instance Monoid b => Monoid (Identity b) where
mempty = mempty
mappend (Identity a) (Identity b) = Identity (a `mappend` b)
instance (Monoid a, Monoid b) => Monoid (Pair a b) whereCopyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x| /** | |
| * This short program will encrypt the user password | |
| * and insert a new record into a mock database. | |
| */ | |
| const Reader = require('fantasy-readers'); | |
| const R = require('ramda'); | |
| const crypto = require('crypto'); | |
| // our mock database | |
| const database = [ |
| import State, {get, put, modify} from 'fantasy-states' | |
| import {prop, compose, map, chain, merge, always} from 'ramda' | |
| // Unfortunately Binary Gendered Baby Page | |
| //========================================== | |
| const babies = [{id: 2, name: 'Anjali', sex: 'F'}, {id: 3, name: 'Antonio', sex: 'M'}] | |
| // isFemale :: Baby -> Bool |
| const daggy = require('daggy'); | |
| const {foldMap} = require('pointfree-fantasy') | |
| const {concat, toUpper, prop, identity, range, compose} = require('ramda'); | |
| // Contravariant functors usually have this shape F(a -> ConcreteType). | |
| // In other words, some type holding a function which is parametric on its input, but not output. | |
| // They don't always have that shape, but it's a good intuition | |
| // Covariant functors are what we're used to, which are parametric in their output | |
| //================================================================ |
| const daggy = require('daggy') | |
| const {compose, curry, map, prop, identity, intersection, union} = require('ramda'); | |
| const inspect = (x) => { if(!x) return x; return x.inspect ? x.inspect() : x; } | |
| // F-algebras | |
| // Fix | |
| // ============ | |
| // Fx is a simple wrapper that does almost nothing. It's much more useful in typed languages to check that we have a recursive f (Fix f) |
| import scalaz._, Scalaz._ | |
| // Adjunction between `F` and `G` means there is an | |
| // isomorphism between `A => G[B]` and `F[A] => B`. | |
| trait Adjunction[F[_],G[_]] { | |
| def leftAdjunct[A, B](a: A)(f: F[A] => B): G[B] | |
| def rightAdjunct[A, B](a: F[A])(f: A => G[B]): B | |
| } | |
| // Adjunction between free and forgetful functor. |
| module Control.Monad.List.Trans where | |
| import Prelude | |
| import Data.List | |
| import Data.Either | |
| import Control.Apply | |
| import Control.Bind | |
| import Control.Monad.Eff |
| module Main where | |
| import Data.Function | |
| import Debug.Trace | |
| import Control.Monad.Trans | |
| import Control.Monad.Cont.Trans | |
| import Control.Monad.Eff | |
| foreign import data Timeout :: ! | |
| type Milliseconds = Number |