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"
-- 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. | |
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. |