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
# -*- coding: utf-8 -*- | |
import requests | |
from bottle import run, route | |
from bs4 import BeautifulSoup | |
import re | |
exp = re.compile(r'\b(\w{6})\b') | |
def replace_6chr_word(word): | |
if len(word) == 6: | |
return word + u"\u2122" |
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
type Request<'i,'o,'k> = 'i * ('o -> 'k) | |
let bindRequest bind f (s,k) = s, fun v -> bind(k v,f) | |
type Id = int | |
type Entity<'e> = Entity of Id * 'e | |
[<Measure>] type money | |
type User = {name : string; email : string; ballance : int<money>} | |
type Product = { name : string; quantity : int; price : int<money>} | |
type Email = {body:string; subject : string} |
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
let howIsMyName t f = f >> Option.map t | |
//mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b | |
type Reader<'environment,'a> = 'environment -> 'a | |
//func application | |
let run environment (action : Reader<_,_>) = action environment |
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
open System | |
/// Type that represents Success/Failure in parsing | |
type Result<'a> = | |
| Success of 'a | |
| Failure of string | |
/// Type that wraps a parsing function | |
type Parser<'T> = Parser of (string -> Result<'T * string>) |
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
type IntG<'a> = IntG of int * 'a | |
let fmap f (IntG(i,v)) : IntG<_>= IntG(i,f v) | |
let mzeroInt32 = 0 | |
let mappendInt32 a b = a + b | |
let destroyInt32 a = () | |
let pairInt32 a = (a,a) | |
//monad | |
let ret x = IntG(mzeroInt32, x) |
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
module FileTest = | |
open System.IO | |
type Resource = Dispose of (unit -> unit) | |
let mzero = Dispose(id) | |
let mappend (Dispose(a)) (Dispose(b)) = Dispose(a >> b) | |
let destroy (Dispose(r)) = r() | |
let rec pair (Dispose(d)) = | |
let lockObj = new obj() |
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
type Request<'i,'o,'k> = 'i * ('o -> 'k) | |
let bindRequest bind f (s,k) = s, fun v -> bind(k v,f) | |
type Id = int | |
type Entity<'e> = Entity of Id option * 'e | |
[<Measure>] type money | |
type User = {name : string; email : string; ballance : int<money>} | |
type Product = { name : string; quantity : int; price : int<money>} | |
type Email = {body:string; subject : string} |
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
module Dsl = | |
type AdderF<'k> = | |
| Add of int * (bool -> 'k) | |
| Clear of 'k | |
| Total of (int -> 'k) | |
let fmap f d = | |
match d with | |
| Add(x,k) -> Add(x,f << k) | |
| Clear k -> Clear (f k) |
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
open System.IO | |
type CoMonoid<'a> = {destroy : 'a -> unit; clone : 'a -> 'a * 'a} | |
type FreeComonoid<'a> = 'a | |
let freeC = { | |
destroy =fun (c: FreeComonoid<'a>) -> (); | |
clone = fun (c: FreeComonoid<'a>) -> (c, c) | |
} |
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
type Maybe<'a> = | |
| Some of 'a | |
| None | |
let fmap f m = | |
match m with | |
| Some(a) -> Some(f a) | |
| None -> None | |
type Free<'a> = |