i dont suppose there are any libraries that ive missed that have a bit more of a “FP” style about GUI programming? using racket/gui
is nice, but feels a quite imperative. Having been used to react for a couple of years and the feel of view being an output of a pur function over state, id like to keep doing that sort of thing
anyone know common lisp?
Only very little.
ok could you please look at this and explain to me what it’s doing
:media-ids (typecase media
(null NIL)
(cons (mapcar #'ensure-media-id media))
(T (list (ensure-media-id media))))
I have learned always to look in the Hyperspec: http://www.lispworks.com/documentation/HyperSpec/Front/index.htm
Let
Let’s find typecase
:
typecase _keyform {normal-clause}*** [otherwise-clause]_ => _result***_
These _macros_ allow the conditional execution of a body of _forms_ in a _clause_ that is selected by matching the _test-key_ on the basis of its _type_. The _keyform_ or _keyplace_ is _evaluated_ to produce the _test-key_. Each of the _normal-clauses_ is then considered in turn. If the _test-key_ is of the _type_ given by the _clauses_’s _type_, the _forms_ in that _clause_ are _evaluated_ as an _implicit progn_, and the _values_ it returns are returned as the value of the *typecase*, *ctypecase*, or *etypecase* _form_.
So, first the type of media
is found.
Then the clause matching the type is found: is it null?, a pair? or T (I think that’s the catch-all).
A Racket user would write . (mapcar #’ensure-media-id media) as (map ensure-media-id media).
I have no idea what media
is - but my guess is that it’s specific to the program you are reading. Not a general construct.
media in this case would an image/video being uploading to a mastodon/pleroma server
the api expects an array
so how should I send media to it?
would i just make a list containing the filename even if I just want to upload one image
Try it.
what would i use for the form field name?
@chris613 There are some, with caveats. FrTime is a functional reactive programming layer on top of racket/gui
, but it’s old and I don’t know anyone who’s actively using it. There is big-bang
from the teaching libraries, which can take you surprisingly far: https://www.youtube.com/watch?v=CnbVCNIh1NA Then there’s lux
, which sets out to be similar to big-bang
but with a more full-featured, production-oriented implementation. If your GUI programming is basically drawing on a canvas and reacting to events, lux
probably already has what you want. I don’t know of any out-of-the-box support for windowing or widgets like button%
, though, and I’ve looked. However, lux
is extensible, so someone could implement such support, and I hope they do!
thanks for the research avenues to follow @philip.mcgrath :smile: