So church encoding of Piano numbers is like this:
type PianoC = (z) -> (z -> z) -> z
zero
just grabs "on zero handler" and returns that
zero :: PianoC
So church encoding of Piano numbers is like this:
type PianoC = (z) -> (z -> z) -> z
zero
just grabs "on zero handler" and returns that
zero :: PianoC
sum(1, 2, 3, 4) == 10 // true | |
sum(1, 2, 3, 4)(1, 2, 3, 4) == 20 // true | |
sum(1)(2)(3)(4)(1)(2)(3)(4) == 20 // true | |
function sum(...args) { | |
function res(...args2) { | |
return sum(_sum(args), _sum(args2)) | |
} | |
// https://javascript.info/object-toprimitive | |
res[Symbol.toPrimitive] = () => _sum(args) |
// prototype of making effect Readerish | |
// https://gist.github.com/safareli/7f60873324cce8880fb4cfa85defe4df | |
export interface EffectRaw<E,A> { (env: E): A } | |
interface EffectPURE<E, A> extends EffectRaw<E,A> { | |
tag: "PURE", | |
_0: A | |
} | |
interface EffectMAP<E, Z, A> extends EffectRaw<E, A>, EffectMAP_OP<Z, A> { |
// modified from https://github.com/safareli/purescript-effect/blob/fast/src/Effect.js | |
/* | |
A computation of type `Effect<a>` in runtime is represented by a function which when | |
invoked performs some effect and results some value of type `a`. | |
With trivial implementation of `Effect` we have an issue with stack usage, as on each `bind` | |
you create new function which increases size of stack needed to execute whole computation. | |
For example if you write `forever` recursively like this, stack will overflow: | |
``` purs | |
function forever(f: Effect<A>): Effect<never> = chain(f, _ => f) | |
``` |
data Count = One | Two | ThreeOrMore | |
type Datum = { count :: Count, char :: Char } | |
data Stat = Stat (Array Datum) | |
instance semigroupCount :: Semigroup Count where | |
append One One = Two | |
append One _ = ThreeOrMore | |
append Two _ = ThreeOrMore |
Dining & drinks in Tbilis
-- | This is module defines modified version `SProxies` and `mkSProxies` from [here][Row] ([depending on this][Utils]). | |
-- | That code was licensed with [Apache License 2.0][License] | |
-- | | |
-- | [Row] - https://github.com/thomashoneyman/purescript-halogen-formless/blob/55e2453f8e0d9169ec3cdccdd8cc09c0e289ffea/src/Formless/Transform/Row.purs#L61-L100 | |
-- | [Utils] - https://github.com/thomashoneyman/purescript-halogen-formless/blob/55e2453f8e0d9169ec3cdccdd8cc09c0e289ffea/src/Formless/Internal/Transform.purs#L23-L35 | |
-- | [License] - https://github.com/thomashoneyman/purescript-halogen-formless/blob/55e2453f8e0d9169ec3cdccdd8cc09c0e289ffea/LICENSE | |
module Type.SProxies | |
( SProxies | |
, SProxies' | |
, mkSProxies |
module Try2 where | |
import Prelude | |
import Control.Monad.Rec.Class (forever) | |
import Data.Tuple (uncurry) | |
import Data.Tuple.Nested ((/\), type (/\)) | |
import Effect (Effect) | |
import Effect.Aff (Aff, launchAff) | |
import Effect.Class (liftEffect) |
I hereby claim:
To claim this, I am signing this object:
-- | performs delay untill next animation frame. | |
untilNextAnimationFrame :: Aff Unit | |
untilNextAnimationFrame = do | |
var <- AVar.empty | |
w <- liftEffect $ window | |
Aff.bracket | |
(liftEffect $ requestAnimationFrame (launchAff_ $ AVar.put unit var) w) | |
(\requestAnimationFrameId -> liftEffect $ cancelAnimationFrame requestAnimationFrameId w) | |
(\_ -> AVar.take var) |