chris613
2020-2-19 18:56:54

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


brentgordon146
2020-2-19 19:57:59

anyone know common lisp?


soegaard2
2020-2-19 19:58:39

Only very little.


brentgordon146
2020-2-19 20:00:49

ok could you please look at this and explain to me what it’s doing


brentgordon146
2020-2-19 20:00:59

:media-ids (typecase media (null NIL) (cons (mapcar #'ensure-media-id media)) (T (list (ensure-media-id media))))


soegaard2
2020-2-19 20:01:51

I have learned always to look in the Hyperspec: http://www.lispworks.com/documentation/HyperSpec/Front/index.htm

Let


soegaard2
2020-2-19 20:02:01

Let’s find typecase:


soegaard2
2020-2-19 20:02:37

typecase _keyform {normal-clause}*** [otherwise-clause]_ => _result***_


soegaard2
2020-2-19 20:02:51

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_.


soegaard2
2020-2-19 20:03:07

So, first the type of media is found.


soegaard2
2020-2-19 20:04:00

Then the clause matching the type is found: is it null?, a pair? or T (I think that’s the catch-all).


soegaard2
2020-2-19 20:04:38

A Racket user would write . (mapcar #’ensure-media-id media) as (map ensure-media-id media).


soegaard2
2020-2-19 20:05:33

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.


brentgordon146
2020-2-19 20:06:03

media in this case would an image/video being uploading to a mastodon/pleroma server


brentgordon146
2020-2-19 20:06:15

the api expects an array


brentgordon146
2020-2-19 20:06:33

so how should I send media to it?


brentgordon146
2020-2-19 20:08:00

would i just make a list containing the filename even if I just want to upload one image


soegaard2
2020-2-19 20:08:40

Try it.


brentgordon146
2020-2-19 20:27:05

what would i use for the form field name?


philip.mcgrath
2020-2-19 20:41:17

@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!


chris613
2020-2-19 21:55:39

thanks for the research avenues to follow @philip.mcgrath :smile: