class Stream[+F[_], +O] extends AnyVal
- A stream producing output of type
O
- May evaluate F effects.
import System.Environment (getArgs) | |
myApp :: [String] -> IO () | |
myApp args = | |
case args of | |
[name] -> putStrLn ("Top of the morning to you, " ++ name) | |
_ -> putStrLn "I only know how to use one argument D:" | |
main :: IO () | |
main = do |
#!/usr/bin/env python | |
import functools | |
import typing as ty | |
from dataclasses import dataclass | |
A = ty.TypeVar("A") | |
B = ty.TypeVar("B") |
import dataclasses as dc | |
import typing as ty | |
import inspect | |
import functools | |
S = ty.TypeVar("S") | |
A = ty.TypeVar("A") | |
B = ty.TypeVar("B") | |
@dc.dataclass(frozen=True) |
{ | |
"name": "Rust color scheme", | |
"rules": [ | |
/* --- grey items --- */ | |
{ | |
"scope": "comment", | |
"foreground": "color(var(black) blend(#fff 50%))", | |
}, | |
/* --- red items --- */ | |
{ |
I have some data which has adjacent entries that I want to group together and perform actions on.
I know roughly that fs2.Pull
can be used to "step" through a stream and do more complicated
logic than the built in combinators allow. I don't know how to write one though!
In the end we should have something like
def combineAdjacent[F[_], A](
shouldCombine: (A, A) => Boolean,
Operation | Input | Result | Notes |
---|---|---|---|
map | F[A] , A => B |
F[B] |
Functor |
apply | F[A] , F[A => B] |
F[B] |
Applicative |
(fa, fb, ...).mapN | (F[A], F[B], ...) , (A, B, ...) => C |
F[C] |
Applicative |
(fa, fb, ...).tupled | (F[A], F[B], ...) |
F[(A, B, ...)] |
Applicative |
flatMap | F[A] , A => F[B] |
F[B] |
Monad |
traverse | F[A] , A => G[B] |
G[F[A]] |
Traversable; fa.traverse(f) == fa.map(f).sequence ; "foreach with effects" |
sequence | F[G[A]] |
G[F[A]] |
Same as fga.traverse(identity) |
attempt | F[A] |
F[Either[E, A]] |
Given ApplicativeError[F, E] |
Using JavaScript libraries from ClojureScript involves two distinct concerns:
Right now, the only single tool that solves these probems reliably, optimally, and with minimal configuration is shadow-cljs
, and so that is what I favor. In paricular, shadow-cljs
lets you install npm modules using npm
or yarn
and uses the resulting package.json
to bundle external dependencies. Below I describe why, what alternatives there are, and what solutions I disfavor at this time.
In the past, I've written composition functions in both Elm and Haskell that take multiple parameters for the leftmost function, i.e. the function that gets applied first.
(All examples here are in Haskell)
Here was my Haskell implemenation (stolen from the web):
compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
[ | |
{ | |
"name":"ABAP", | |
"type":"programming", | |
"extensions":[ | |
".abap" | |
] | |
}, | |
{ | |
"name":"AGS Script", |