Skip to content

Instantly share code, notes, and snippets.

@statusfailed
statusfailed / Expr.hs
Created January 7, 2016 19:36
Broken parser: the commented out definition of "term" causes the parser to hang
{-# LANGUAGE DeriveFunctor #-}
module Expr where
import Data.Monoid
data Expr a
= Lit a
| Neg (Expr a)
| Add (Expr a) (Expr a)
| Sub (Expr a) (Expr a)
@statusfailed
statusfailed / Elm JSON decode example
Created November 27, 2015 09:28
Example of JSON decoding in elm
import Html exposing (Html, text)
import Signal exposing (constant)
import Json.Decode as Json exposing ((:=))
type alias Person =
{ name : String
, age : Int
}
personDecoder : Json.Decoder Person
@statusfailed
statusfailed / groupBy Machine
Last active August 29, 2015 14:05
A question on how to write a "groupBy" machine using Edward Kmett's machines library
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Prelude hiding (id, (.))
import Control.Category
import Control.Applicative
import Control.Monad
import Control.Monad.Trans
import Control.Monad.IO.Class