frp

How do I get the current time in Elm 0.17/0.18?

会有一股神秘感。 提交于 2019-11-27 14:05:02
问题 I had asked this question already: How do I get the current time in Elm? And answered it by writing my own ( now deprecated ) variant of start-app: http://package.elm-lang.org/packages/z5h/time-app/1.0.1 Of course the Elm architecture has since changed, and my old way of doing things no longer works, because there are no signals or Time.timestamp . So.... Suppose I build an app with the standard update function signature: update : Msg -> Model -> (Model, Cmd Msg) I'd like to timestamp my

Kleisli Arrow in Netwire 5?

不想你离开。 提交于 2019-11-27 08:06:12
问题 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

Console interactivity in Netwire?

妖精的绣舞 提交于 2019-11-27 06:22:14
问题 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 _

RxSwift merge different kind of Observables

杀马特。学长 韩版系。学妹 提交于 2019-11-27 03:53:52
问题 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. 回答1: 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

Why recursive `let` make space effcient?

无人久伴 提交于 2019-11-26 22:42:43
问题 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

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

帅比萌擦擦* 提交于 2019-11-26 18:52:28
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . 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

Specification for a Functional Reactive Programming language

为君一笑 提交于 2019-11-26 18:42:30
问题 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

RxJS Promise Composition (passing data)

别来无恙 提交于 2019-11-26 07:37:21
问题 I\'m brand new to Rx and am finding it difficult to find documentation on composing promises such that data from the first promise is passed into the second and so on. Here\'s three very basic promises, the calculations on the data aren\'t important, just that something async has to be done using data from the previous promise. const p1 = () => Promise.resolve(1); const p2 = x => { const val = x + 1; return Promise.resolve(val); }; const p3 = x => { const isEven = x => x % 2 === 0; return

What is (functional) reactive programming?

旧城冷巷雨未停 提交于 2019-11-25 23:50:29
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I\'ve read the Wikipedia article on reactive programming. I\'ve also read the small article on functional reactive programming. The descriptions are quite abstract. What does functional reactive programming (FRP) mean in practice? What does reactive programming (as opposed to non-reactive programming?) consist of? My