Reflex-FRP - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Sridhar Ratnakumar

I worked for Obsidian in the past, but continue to use Obelisk in hobby projects. Can't imaging using anything else (like Elm or PureScript).

Ben Kolera

Yeah. Esp once fancy stuff like Rhyolite gets into the mix, it's hard to think about using anything else anymore. I'd miss being able to write correct UI abstractions and not have to worry about magic breaking. :slight_smile:

Ben Kolera

Or Elm's verbosity. It's hard to write incorrect elm code, but it does get pretty verbose without all of the nice types.

Rizary

When it comes to CSS, what is the preferred way to develop CSS with reflex app?

Ben Kolera

I like Clay, but I don't think that there is a universally preferred way.

Joel McCracken

Are there examples/docs for how to do JS->HS and HS->JS FFI with ghcjs yet?

Cyril Valyavin

How do I use reflex-vty as a Nix dependency? The nixpkgs entry is broken so I downloaded it from github, now what exactly should I put in the overrides? I've tried using release.nix but it's not working and I'm not sure what it even does.

EDIT: Figured out. https://github.com/reflex-frp/reflex-vty/issues/18

I'm using Nix to manage dependencies and Cabal to build my packages inside a Nix shell. This package is marked as broken in nixpkgs (as reflex-related packages normally are) so I've tried t...
Sridhar Ratnakumar

A project template for writing modern web apps in reflex (database, websocket, real-time notifications, live reload, etc): https://github.com/3noch/something

Contribute to 3noch/something development by creating an account on GitHub.
Matthias Putz

This is a pretty awesome repository - I was trying to use and adapt obsidiansystem's rhyolite for a while but failed (not good enough in Haskell yet to figure out how to combine all the pieces to get a nice chain from backend to frontend ; especially failing on the functorToWire for the Query... I got something compiling but then making sense out of having to implement a Filterable instance etc. made me giving up). Sadly this repo is not mentioned in the rhyolite lib nor anywhere else :see_no_evil: . So thanks @Sridhar Ratnakumar , it's worth a lot to me :) .

Cyril Valyavin

What is Rhyolite even? Is there any documentation?

Sridhar Ratnakumar

It's mentioned in my Haskell zettelkasten :smiley: https://haskell.srid.ca/2012401.html

Cyril Valyavin

Yeah well it doesn't say what it is for...

Sridhar Ratnakumar

Yea, it is a matter of creating a 'Rhyolite' zettel and linking it accordingly. Well, rhyolite provides features _still_ missing in obelisk: database notifications, websocket support, real-time communication (and database notifications going to browser through Dynamic, aka. ViewSelector), etc..

Matthias Putz

So - after hooking up everything, i.e. handlers and models and all - for example you use queryDyn in the frontend to request an interest in a certain set of data. In the backend you then provide these data and even update this set of data automatically on change (which is done via PostgreSQL 's NOTIFY and LISTEN). So you kind of get real-time updates for your queries (similar to what Meteor is doing https://www.meteor.com/).
But this is only one example, I guess. Rhyolite is a kind of collection of yet-to-polish stuff for obelisk :) . But the feature just mentioned is what I am really interested in :).

Sridhar Ratnakumar

@Matthias Putz Exactly. Could I steal your words for my Zettelkasten? :-D

Ben Kolera

Rhyolite is not publicly talked about for good reason! Not because it's a secret but more that it's a bit crufty and unpolished, and due to be replaced with something better (technically and in terms of polish) this year. :slight_smile:

Ben Kolera

If you've got something to write right now, go for it, but I wouldn't learn rhyolite "just for funsies" right now unless you have an immediate use. :

Sridhar Ratnakumar

Ben Kolera said:

Rhyolite is not publicly talked about for good reason! Not because it's a secret but more that it's a bit crufty and unpolished, and due to be replaced with something better (technically and in terms of polish) this year. :slight_smile:

That's good to hear. What more can you tell about the new thing? Ve...? :-)

Ben Kolera

It's not a secret. There was a zurihac talk on it that unfortunately got lost. And then an internal OS talk on it where the footage also got lost. Cursed.

Ben Kolera

It's called incremental view, and it involves a rhyolite like thing with a lot more automation of mapping the changes to the db and back out rather than the manual writing of selectors and handlers.

Ben Kolera

There are lots of bugs that you make in rhyolite apps. This is trying to move towards fixing that.

Cyril Valyavin

Great to see the ecosystem around Reflex growing, it really feels like the right way

Matthias Putz

Ah, cool. So is it using WAL of Postgres to achieve this? (can't remember the zurihac talk in detail). Can't wait to explore this, let us here if there is some time-line (so anything before 31.12. :D)

Sridhar Ratnakumar

@Ben Kolera Do you work for Obsidian now? Is there a repo for incremental view? Or is it this one: https://github.com/obsidiansystems/vessel

Functor-parametric containers. Contribute to obsidiansystems/vessel development by creating an account on GitHub.
Ben Kolera

Yes I work for OS now. And not yet. It's being developed internally atm and will be released when it is ready for public consumption (and will be FOSS just like reflex).

Ben Kolera

Oh, and the reason for this is that it'll actually be proper part of obelisk. :slight_smile:

Joel McCracken

So is there any documentation/examples of how to call/invoke a HS function from JS?

Torsten Schmits

you want to write native js in a reflex app?

Joel McCracken

I want to be able to interact with my haskell application if I need to

Torsten Schmits

I'm just starting out but my understanding is that you can access all dom events from your haskell app

Joel McCracken

so i mean the issue is if I have some external component and it needs to invoke a fn call

Torsten Schmits

right, I think I saw a link about using external js somewhere

Ben Kolera

Depending on whether you are going to be using jsaddle at all for dev, you can either use the jsaddle-dom stuff to interact with stuff it has generated apis for or exec raw JS calls in JSM.

If you aren't using jsaddle and always compiling with ghcjs, you can just use GHCJS FFI to javascript.

Ben Kolera

If you are doing obelisk or r-p, you are probably wanting jsaddle. GHCJS compiles can be slow enough to dodge them for development.

Torsten Schmits

I find it pretty hard to get a grasp of how all of those components relate to each other

Ben Kolera

Yeah, it's a right PitA because there's next to no doco. :frown:

Torsten Schmits

yeah the missing docs are really frustrating

Ben Kolera

With obelisk it has jsaddle built in though. You can't use FFI js there so if you go that route only bother looking at JSM and Jsaddle.

Joel McCracken

This all sounds really hard. But anyway i dont actually ahve a direct need for what I am asking, maybe it is unncessary. I just was hoping to be able to check the box that its possible. Maybe I can hack something together though that would allow me to send/call my haskell code from JS

Matthias Putz

Joel McCracken said:

This all sounds really hard. But anyway i dont actually ahve a direct need for what I am asking, maybe it is unncessary. I just was hoping to be able to check the box that its possible. Maybe I can hack something together though that would allow me to send/call my haskell code from JS

I guess this is not exactly what you are asking for, but just for the record: google-maps-reflex does "call a hs function" from JS, which results in an Event in the reflex application. See https://github.com/cfraz89/google-maps-reflex/blob/master/src/GoogleMapsReflex/MapsLoader.hs . That's due to the fact that when you include the Google Maps script, you attach a callback name of the global JS scope which is called as soon as the script is loaded/ready.

Google Maps for Reflex. Contribute to cfraz89/google-maps-reflex development by creating an account on GitHub.
Ben Kolera

Yeah the complication there is understanding what jsaddle is doing for you, not using it yourself. It's not very documented, so it's pretty weird. That example is using jsaddle so you can easy drop that into an obelisk app. It's just things that to a foreign import of js code that you have to be wary of. As a user it's no harder to use than the existing GHCJS Dom bindings (because they are generated from the same source data) but you should definitely seek to understand this before putting jsaddle code in production apps just so that you are aware of things in case anything breaks weirdly in development when using jsaddle warp.