Skip to content
/ hessian Public

🌾 lightweight observables and iterables for grain-lang

Notifications You must be signed in to change notification settings

av8ta/hessian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hessian

grain streams inspired by javascript callbags

🌾 A standard for callbacks that enables lightweight observables and iterables

Photo by Clem Onojeghuo on Unsplash

WIP still being built!

Usage

import * from "./hessian"
import * from "./types"
import { (|>) } from "./pipe"

let producer = fromList([1, 2, 3]) |> map(v => v + 10)

let operators = producer |> map(v => v + 10) |> map(v => v + 10)

operators |> forEach(print)
31
32
33
// serialise.gr
...
record Human {
  mut message: String,
}

let value = { message: "Hi from Bob", }
print(Bytes.toString(marshal(value)))
// deserialise.gr
...
let stdinOptions = {
  file: Fd(File.stdin),
  rwFlags: [],
  size: 1024,
}: Sources.ReadFileOptions

let deserialise = message => {
  let parsed = Result.map((bob: Human) => bob.message, unmarshal(message))
  Result.toOption(parsed)
}

readFile(stdinOptions)  |>
  map(Bytes.fromString) |>
  map(deserialise) |>
  forEach(print)
grain serialise | grain deserialise
Some("Hi from Bob")

About

🌾 lightweight observables and iterables for grain-lang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages