This blog post series has moved here.
You might also be interested in the 2016 version.
This blog post series has moved here.
You might also be interested in the 2016 version.
| open System | |
| open System.IO | |
| open System.Text | |
| open System.Globalization | |
| open System.Text.RegularExpressions | |
| let l1 = 1.0 | |
| let l2 = 2.0 | |
| let ttlTrue = 2.3 |
sudo yum update
sudo yum install xmonad ghc-xmonad-contrib{,-devel} xmobar
Or: functor? I 'ardly know 'er!
Monads are difficult to explain without sounding either patronizing or condescending: I would sound patronizing if I came up with some facile analogy and I would be condescending to describe it categorically.
Instead, I'll frame a problem and piece-by-piece solve the problem with what will turn out to be a monad.
| import static java.lang.System.*; | |
| import java.util.function.BiFunction; | |
| import java.util.function.Function; | |
| // Implementation of a pseudo-GADT in Java, translating the examples from | |
| // http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf | |
| // The technique presented below is, in fact, just an encoding of a normal Algebraic Data Type | |
| // using a variation of the visitor pattern + the application of the Yoneda lemma to make it | |
| // isomorphic to the targeted 'GADT'. |
| package bar.foo.lenses; | |
| import java.util.function.BiFunction; | |
| import java.util.function.Function; | |
| public class Lens<A, B> { | |
| private final Function<A, B> getter; | |
| private final BiFunction<A, B, A> setter; |
It's like creating the front end and back end of a compiler inside Haskell without the need of Template Haskell!
Write your DSL AST as a Free Monad, and then interpret the monad any way you like.
The advantage is that you get to swap out your interpreter, and your main code
The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.
However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on
Make sure you have installed Homebrew and (Homebrew-Cask)[http://caskroom.io/].
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebrew-cask
brew install caskroom/cask/brew-cask
| module FilterElems where | |
| import Data.List | |
| import Control.Monad | |
| -- abstract tuple comparison | |
| sortTup f = | |
| case ord of | |
| EQ -> snd f | |
| _ -> ord | |
| where ord = fst f |