frp

Kleisli Arrow in Netwire 5?

淺唱寂寞╮ 提交于 2019-11-28 14:06:00
I am trying to create a game using Haskell + Netwire 5 (+ SDL). Now I am working on the output part, where I would like to create wires that read in some game state and output the SDL surfaces to be blitted on screen. However, the problem is that SDL surfaces are contained in IO monad, so any function that creates such surfaces must have type a -> IO b . Of course, arr does not construct a Wire from a -> m b . However, since the type signature of a wire is (Monad m, Monoid e) => Wire s e m a b , it looks quite like a Kleisi Arrow, but I cannot find a suitable constructor for making such a wire

Console interactivity in Netwire?

两盒软妹~` 提交于 2019-11-28 11:35:17
I am testing with the Netwire haskell library and made it work with a simple time wire: import Control.Wire import Prelude hiding ((.), id) import Control.Monad.IO.Class import Data.Functor.Identity import System.IO wire :: (HasTime t s) => Wire s () m a t wire = time run :: (HasTime t s, MonadIO m, Show b, Show e) => Session m s -> Wire s e m a b -> m () run session wire = do (dt, session') <- stepSession session (wt', wire') <- stepWire wire dt $ Right undefined case wt' of -- | Exit Left _ -> return () Right x -> do liftIO $ do putChar '\r' putStr $ either (\ex -> show ex) show wt' hFlush

Fulfilling all function arguments in order before invoking

不打扰是莪最后的温柔 提交于 2019-11-28 11:03:46
问题 I'm trying to understand how the following zip function (esp. the invoke function) can be made more functional. The issue I've got is that the invoke method has to wait for both the left and right side to be filled before it can dispatch the values. The values have to be called in order so that the correct values are zipped, otherwise I would consider a curry/partial function to fulfill this. Is there anything that I could use that could remove this hinderance. function zip(state, a, b) { var

RxSwift merge different kind of Observables

99封情书 提交于 2019-11-28 10:54:48
How should I merge 2 different types of Observable s in RxSwift? For example: var a: Observable<Int> var b: Observable<Void> Observable.of(a,b).merge() is not possible because of type parameter difference. To merge them, they need to have the same type for their Element . So, one option is to throw away their type information and cast to AnyObject . Now they can be merged: let stringSubject = PublishSubject<String>() let stringObservable = stringSubject.asObservable().map { $0 as AnyObject } let intSubject = PublishSubject<Int>() let intObservable = intSubject.asObservable().map { $0 as

Advantage of Functional Reactive Programming over event-listeners

雨燕双飞 提交于 2019-11-28 03:37:16
问题 I've been hearing a lot about functional reactive programming, and decided to check out what the big deal is. Going through the bacon.js documentation, it seems that the main difference is that instead of setting an event listener on a component, I create an event stream on it, and pass the event handler into the stream instead. In other words, all I really did was move the event handler from the component to the event stream. Is that it? If so, what's the big advantage of doing this? 回答1: Is

哈尔滨幼儿师专项目部署安装过程小记

北城以北 提交于 2019-11-27 22:01:18
1、U盘安装Centos7.6,在物理机上会发生问题: 解决办法: https://blog.csdn.net/qq_28822933/article/details/83472138 https://jingyan.baidu.com/article/19020a0a73b250529d284294.html tab键会出现安装引导vmlinuz initrd.img inst.stage2=hd:LABEL=centOS\x207\x20x86_64 rd.live.check quiet把这段改成vmlinuz initrd.img inst.stage2=hd:/dev/sdb4 quiet 回车 然后ctrl+x就开始安装系统了 2、关闭防火墙: #停止firewallsystemctl stop firewalld.service #禁止firewall开机启动 systemctl disable firewalld.service 3、关闭selinux #临时关闭 setenforce 0 #永久关闭 vi /etc/selinux/config 将SELINUX=enforcing改为SELINUX=disabled 设置后需要重启才能生效 4、修改shh端口:26611 vi /etc/ssh/sshd_config #Port 22 ---->Port

Why recursive `let` make space effcient?

假装没事ソ 提交于 2019-11-27 18:41:49
I found this statement while studying Functional Reactive Programming, from "Plugging a Space Leak with an Arrow" by Hai Liu and Paul Hudak ( page 5) : Suppose we wish to define a function that repeats its argument indefinitely: repeat x = x : repeat x or, in lambdas: repeat = λx → x : repeat x This requires O(n) space. But we can achieve O(1) space by writing instead: repeat = λx → let xs = x : xs in xs The difference here seems small but it hugely prompts the space efficiency. Why and how it happens ? The best guess I've made is to evaluate them by hand: r = \x -> x: r x r 3 -> 3: r 3 -> 3: 3:

What's the status of Scala.React? [closed]

前提是你 提交于 2019-11-27 17:07:55
I just read Deprecating the Observer Pattern and found it absolutely fascinating. What's the status of the Scala.React package described in the document? I found one tarball of a snapshot of Scala.React but there doesn't seem to be much documentation or active maintenance. I also found ScalaFX, which looks like it might be related to reactive programming, but is similarly unmaintained. Are there any projects out there that build on the ideas in this paper to create a GUI framework based on reactives? Alex Cruise UPDATED : As William Harvey points out below , there is recent progress! Like you,

Specification for a Functional Reactive Programming language

﹥>﹥吖頭↗ 提交于 2019-11-27 16:35:32
I am looking at messing around with creating a functional reactive framework at some point. I have read quite a lot about it and seen a few examples but I wanted to get a clear idea of what this framework would HAVE to do to be considered an FRP extension/dsl. I'm not really concerned with implementation problems or specifics etc but more as to what would be desired in a perfect world situation. What would be the key operations and qualities of an ideal functional reactive programming language? Conal I'm glad you're starting by asking about a specification rather than implementation first.

Chaining promises with RxJS

拥有回忆 提交于 2019-11-27 14:48:19
问题 I'm new to RxJS and FRP in general. I had the idea of converting an existing promise chain in my ExpressJS application to be an observable for practice. I am aware that this probably isn't the best example but maybe someone can help shed some light. What I'm trying to do : I have two promises - prom1 and prom2 I want prom1 to run before prom2 If prom1 sends a reject(err), I want to cancel prom2 before it starts. I want the error message prom1 returns to be available to the onError method on