This file contains 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 DoubleCont where | |
import Control.Monad.Cont | |
reset :: ContT a (ContT r m) a -> ContT b (ContT r m) a | |
reset e = ContT $ \k -> | |
ContT $ \m -> | |
runContT (runContT e return) | |
(\r -> runContT (k r) m) |
This file contains 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
/** | |
* This demonstrates problems of using burrido with most (and in fact with any | |
* other multi-answer monads). It works only if `most` doesn't contain other | |
* effect besides pure stream comprehension effects, or effects we don't care | |
* about. | |
*/ | |
import {from,of,fromPromise} from 'most' | |
import Monad from 'burrido' | |
const MM = Monad({ |
This file contains 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
import {from,of,fromPromise,Stream} from 'most' | |
const M = require('@mfjs/core') | |
import CC from '@mfjs/cc' | |
M.profile('regenerator') | |
const MM = CC.makeMonad(Stream.prototype.chain,of) | |
let cnt = 0 | |
function updateDb() { |
This file contains 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
/** | |
* This demonstrates problems of using burrido with most (and in fact with any | |
* other multi-answer monads). It works only if `most` doesn't contain other | |
* effect besides pure stream comprehension effects, or effects we don't care | |
* about. | |
*/ | |
import {Observable} from 'rx' | |
import Monad from 'burrido' | |
const { just: pure, fromPromise,from } = Observable |
This file contains 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
import {Observable} from 'rx' | |
const M = require('@mfjs/core') | |
const MM = require('@mfjs/rx')() | |
M.profile('regenerator') | |
const { just: pure, fromPromise,from } = Observable | |
let cnt = 0 | |
function updateDb() { | |
return new Promise(resolve => { |
This file contains 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
async function consume(input) { | |
for await(const i of input) {} | |
} |
This file contains 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
function main(state) { | |
for(;;) { | |
switch(state.control) { | |
case "init": | |
state.action = "read" | |
state.control = "loop1" | |
return | |
case "loop1": | |
const i = state.value | |
if (i.type === "pointerdown") { |
This file contains 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
async function consume(input) { | |
const iter = input[Symbol.asyncIterator]() | |
for(let i;(i = await iter.next()).done;) {} | |
} |
This file contains 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
async function* animRemove(input) { | |
for await(const i of input) { | |
if (i.type === "remove") { | |
const el = i.element | |
const box = el.getBoundingClientRect() | |
for await(const j of anim()) { | |
el.style.width = `${box.width*(1-j)}px` | |
el.style.height = `${box.height*(1-j)}px` | |
el.style.top = `${box.y+window.pageYOffset+box.height*j/2}px` | |
el.style.left = `${box.x+window.pageXOffset+box.width*j/2}px` |
This file contains 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
async function* stopThread(input) { | |
for await(const i of input) { | |
yield i | |
if (i.type === "drop" || i.type === "dragcancel" || i.type === "remove") | |
break | |
} | |
} |
OlderNewer