Skip to content

Instantly share code, notes, and snippets.

Lev Gorodinski eulerfx

Block or report user

Report or block eulerfx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eulerfx
eulerfx / app.fsx
Created Mar 26, 2014
F# http service with HyperF
View app.fsx
#load "HyperF.fsx"
open HyperF
open Route
let service =
[
Get("/resource/:id") => fun (req,ri) -> "hello world!" |> HttpRes.plainText
@eulerfx
eulerfx / 0_Use.fs
Last active Aug 29, 2015
F# random value combinators based on state monad and computation workflows
View 0_Use.fs
type Event = {
name : string
date : DateTime
code : int
}
let randEvent : Rand<Event> =
let name = Rand.String (Rand.IntRange 10 15)
let date = Rand.DateTime (DateTime(2014, 3, 26)) (DateTime(2015, 3, 26))
let code = Rand.IntRange 1000 9999
@eulerfx
eulerfx / 0_Use.fs
Last active Aug 29, 2015
F# CSV parsing and validation
View 0_Use.fs
type MerchantSkuImported with
static member Zero = { MerchantSkuImported.id = null ; merchant_id = null ; merchant_sku = null ; upc = null ; manufacturer = null ; brand = null ; part_no = null ; title = null ; description = null ; bullets = List.empty ; category = 0 ; category_path = List.empty ; multi_pack_quantity = None ; shipping_weight = None ; package_length = None ; package_width = None ; package_height = None ; main_image_url = None ; other_image_url = None ; price = None ; quantity = None ; start_selling_date = None }
static member MerchantSku = (fun (x:MerchantSkuImported) -> x.merchant_sku) |> Lens.create <| fun v x -> { x with merchant_sku = v }
static member UPC = (fun (x:MerchantSkuImported) -> x.upc) |> Lens.create <| fun v x -> { x with upc = v }
static member Title = (fun (x:MerchantSkuImported) -> x.title) |> Lens.create <| fun v x -> { x with title = v }
static member Brand = (fun (x:MerchantSkuImported) -> x.brand) |> Lens.create <| fun v x -> { x with brand = v }
s
@eulerfx
eulerfx / AsyncIO.md
Last active Aug 29, 2015
Rx effectful observers
View AsyncIO.md

Synchronous

  • () -> (() -> a) - sequence (IEnumerable)

with arrows reversed:

  • (a -> ()) -> () - observable (IObservable)

Everything is fine and we have duality between pull and push. In particular, () -> a is dual to a -> ().

@eulerfx
eulerfx / JsonCursor.fs
Created Jun 23, 2014
FSharp.Data JsonValue zipper
View JsonCursor.fs
type JsonPath =
| Top /// The root of the JsonValue.
| Node of i:int * parent:JsonValue * path:JsonPath /// A node within a JsonValue: a record property or an array item.
type JsonZipper = JsonZipper of current:JsonValue * path:JsonPath
module JsonCursor =
let private expectRecord() = failwith "Invalid cursor state: JsonValue.Record expected!"
@eulerfx
eulerfx / EventStore.fsi
Last active Aug 29, 2015
F# EventStore API
View EventStore.fsi
type Stream = string
type EventType = string
type ExpectedVersion = int
type EventData = byte[]
type EventMetadata = byte[]
type ResolveLinks = bool
type From = int
type BatchSize = int
type BufferSize = int
type CheckpointStore = (unit -> Async<int option>) * (int -> Async<unit>)
@eulerfx
eulerfx / 0_LensStateMutation_Usage.fs
Last active Aug 29, 2015
Imperative-style update syntax with F# lenses and state/costate.
View 0_LensStateMutation_Usage.fs
type MerchantSku = {
name : string
price : decimal
} with
static member Name = Lens.create (fun x -> x.name) (fun v x -> { x with name = v})
static member Price = Lens.create (fun x -> x.price) (fun v x -> { x with price = v})
let sku = { name = "Shaving Cream" ; price = 10m }
@eulerfx
eulerfx / 0_Usage.fs
Last active Aug 29, 2015
Imperative style update syntax for FSharp.Data JsonValue using lenses
View 0_Usage.fs
let jsonStr = """
{
"itemSize": {
"width": "hello"
},
"tags": ["foo","bar"]
}
"""
let json = JsonValue.Parse jsonStr
@eulerfx
eulerfx / HopacRx.fs
Last active Aug 29, 2015
Push sequences with F# Hopac
View HopacRx.fs
namespace Marvel.Hopac
open System
open Hopac
open Hopac.Extra
open Hopac.Job.Infixes
/// An effectful observer.
type RxObs<'a> = 'a option -> Job<unit>
@eulerfx
eulerfx / HopacSeq.fs
Last active Aug 29, 2015
Hopac-based seq merge
View HopacSeq.fs
namespace Marvel.Hopac
open Hopac
open Hopac.Extra
open Hopac.Job.Infixes
open Hopac.Alt.Infixes
/// Different representation of EagerSeq<'a>
type HopacSeq<'a> = Job<HopacSeqStep<'a>>
You can’t perform that action at this time.