Skip to content

Instantly share code, notes, and snippets.

View louissalin's full-sized avatar

Louis Salin louissalin

View GitHub Profile
-- 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.
@louissalin
louissalin / gist:e9713582aa83a0cfa446
Created January 13, 2015 19:58
experimenting with parseMaybe

using this Aeson example:

do result <- decode "{\"name\":\"Dave\",\"age\":2}"
      flip parseMaybe result $ \obj -> do
        age <- obj .: "age"
        name <- obj .: "name"
        return (name ++ ": " ++ show (age*2))

Just "Dave: 4"
{-# LANGUAGE OverloadedStrings, GADTs #-}
import Prelude
import Control.Monad.Operational
data StackInstruction a where
Push :: Int -> StackInstruction ()
Pop :: StackInstruction Int
type StackProgram a = Program StackInstruction a
import Control.Applicative
import Control.Monad
import Data.List
import System.Random
-- Generates a binary maze. For each cell in the maze, decide to either
-- open up the cell to the north or to the east, unless we're at the
-- rightmost or topmost cells, in which case we have no choice as to
-- where to put the opening.