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"
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. |
{-# 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 |
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. | |
import Text.Regex | |
subRegex (mkRegex "\d") "some digits: 123" "*" | |
<interactive>:19:21: | |
lexical error in string/character literal at character 'd' |
main = do | |
config <- readDbConfig | |
let runAction = withConnection config | |
S.scotty 3000 $ do | |
S.get "/" $ do | |
res <- liftIO . runAction $ getOpportunity | |
S.json $ Opportunities res | |
S.post "/opportunities/" $ do | |
requestBody <- S.body |
require 'values' | |
# value objects | |
User = Value.new(:name) | |
u1 = User.new("Louis") | |
u2 = User.new("Bob") | |
u3 = User.new("Louis") |
$ sudo gem install guard | |
$ sudo gem install guard-shell | |
links: | |
- https://github.com/guard/guard | |
- https://github.com/guard/guard-shell | |
Create a file named "Guardfile" in the root of the project and put the following lines in it: | |
guard :shell do |
package test | |
case class Address(no: Int, street: String, city: String, state: String, zip: String) | |
trait LabelMaker[T] { | |
def toLabel(value: T): String | |
} | |
trait Plus[T] { | |
def plus(a1: T, a2: T): T |
$ mkdir git-exercises
$ cd git-exercises
$ git init
$ touch a.txt
$ git add -A
$ git commit -m 'empty file'
##let’s work on a small feature