Skip to content

Instantly share code, notes, and snippets.

@L8D

L8D/thing.hs

Last active Aug 29, 2015
Embed
What would you like to do?
-- How I should be able to define a model
tasks :: [a] -> Either a a -> [a]
tasks ts = either (:ts) (`delete` ts)
-- How I should be able to define an event stream
eventStream = scanl tasks . map (Left . getValue . getTarget) . filter ((== 13) . getWhich)
main = someWayToSelectElementAndMakeEventStreams "#input-box" "keydown"
>>= eventStream
>>= mapM renderMyList
var input = Pancetta.fromEvent($('#input-box')), 'keydown');
var messages = input.filter(function(event) {
return event.which === 13;
}).map(function(event) {
return event.target.value;
});
messages.scan([], function(tasks, task) {
return tasks.concat([task]);
}).subscribe(renderMyList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.