Requires:
-
Homebrew (http://mxcl.github.io/homebrew/)
-
Ruby
Verify Homebrew is not sick:
brew doctor
sudo apt-get build-dep vim | |
hg clone https://vim.googlecode.com/hg/ vim | |
cd vim | |
sudo apt-get install ruby-dev python3-dev | |
./configure --with-features=huge --enable-gui=gnome2 --enable-rubyinterp --enable-python3interp --with-python-config-dir=/usr/lib/python3.3/config-3.3m-i386-linux-gnu | |
sudo checkinstall |
Getting Real | |
============ | |
URL | |
--- | |
http://gettingreal.37signals.com/ | |
Synposis | |
-------- |
-- What is the big deal? Took all of 2 minutes to write this | |
module Main where | |
main :: IO () | |
main = mapM_ (putStrLn . fizzbuzz) [1..100] | |
fizzbuzz :: Int -> String | |
fizzbuzz x = divisors `orElse` show x | |
where | |
divisors = concatMap test [(3,"Fizz"),(5,"Buzz"),(7,"Baz")] |
Requires:
Homebrew (http://mxcl.github.io/homebrew/)
Ruby
Verify Homebrew is not sick:
brew doctor
-- This is the configuration file for the 'cabal' command line tool. | |
-- The available configuration options are listed below. | |
-- Some of them have default values listed. | |
-- Lines (like this one) beginning with '--' are comments. | |
-- Be careful with spaces and indentation because they are | |
-- used to indicate layout for nested sections. | |
{-# LANGUAGE DeriveDataTypeable, QuasiQuotes #-} | |
module Main where | |
import Data.Char (toUpper) | |
import Data.List (intersperse) | |
import Data.String.Interpolate (i) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = getArgs >>= putStrLn . makeInsult |
type Elem = [String] | |
width :: Elem -> Int | |
width e | |
| (c:_) <- e = length c | |
| otherwise = 0 | |
height :: Elem -> Int | |
height = length |
löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:
loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
where xs = fmap ($ xs) fs
From Edward's comment here - https://www.reddit.com/r/haskell/comments/4cfxri/relationship_between_operational_monad_and_oleg/d1hxmfr | |
You can view Operational f as sugar for Free (Coyoneda f). | |
Coyonedamakes a functor out of anything of kind * -> *. This is good and bad, depending on how you use the result. If you inspect it multiple times and do more fmap's etc, you may wind up lifting and lowering repeatedly and converting back and forth between f and Coyoneda f does require an fmap on the roundtrip. | |
Similarly, Free makes a monad by using any Functor worth of instructions. | |
These notions compose very naturally. Now your 'instructions' don't have to start as a Functor, they just get to be anything of kind * -> *. |