This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Cis194.Hw.SExpr> :r | |
[2 of 2] Compiling Cis194.Hw.SExpr ( src/Cis194/Hw/SExpr.hs, interpreted ) | |
src/Cis194/Hw/SExpr.hs:84:38: | |
Couldn't match type `SExpr' with `Atom' | |
Expected type: [SExpr] -> Atom | |
Actual type: [SExpr] -> SExpr | |
In the first argument of `pure', namely `(Comb)' | |
In the first argument of `(<*>)', namely `pure (Comb)' | |
In the second argument of `(<|>)', namely |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Ex. 2 - implement an Applicative instance for Parser | |
-- | |
-- A. pure a represents the parser which consumes no input | |
-- and successfully returns a result of a. | |
-- | |
-- B. p1 <*> p2 represents the parser which first runs p1 | |
-- (which will consume some input and produce a | |
-- function), <----- doesn't this produce a Maybe (a, String) ???? | |
-- ...then passes the remaining input to p2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Debug.Trace | |
div' :: Integer -> Integer -> Integer | |
div' x y | |
| trace ("x is: " ++ (show x) ++ " and y is: " ++ (show y)) False = undefined | |
| otherwise = x `div` y | |
-- guards are evaluated from top to bottom until a match is found, so we fire off | |
-- our call to trace (which returns False) and move on to the next guard (which is | |
-- our real implementation). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import barrister | |
import urllib2 | |
import sys | |
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
password_mgr.add_password(None, 'http://localhost:3000/','admin','admin') | |
auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) | |
trans = barrister.HttpTransport("http://localhost:3000/v1/todos", handlers=[auth_handler]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import barrister | |
import urllib2 | |
import sys | |
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
password_mgr.add_password(None, 'http://localhost:3000/','admin','admin') | |
auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) | |
trans = barrister.HttpTransport("http://localhost:3000/v1/todos", handlers=[auth_handler]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize the API client | |
function initApp(callback) { | |
function transport(req, callback) { | |
var settings = { | |
type: 'POST', | |
contentType: 'application/json', | |
data: JSON.stringify(req), | |
beforeSend: function(xhr) { | |
// set the Authorization header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/coopernurse/barrister-go" | |
"net/http" | |
t "./todos" | |
s "./store" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import barrister | |
from bottle import run, post, request | |
from store import Store, RecordNotFound, UserDataInvalid, MaxTodosExceeded | |
from functools import wraps | |
import sys | |
def guard(*exceptions): | |
errors = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize the API client | |
function initApp(callback) { | |
function transport(req, callback) { | |
var settings = { | |
type: 'POST', | |
contentType: 'application/json', | |
data: JSON.stringify(req), | |
beforeSend: function(xhr) { | |
// set the Authorization header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize the API client | |
function initApp(callback) { | |
function transport(req, callback) { | |
var settings = { | |
type: 'POST', | |
contentType: 'application/json', | |
data: JSON.stringify(req), | |
beforeSend: function(xhr) { | |
// set the Authorization header |