On the one hand, I much prefer server-side generated HTML with a little bit of Javascript to enhance parts of it. On the other hand, once said enhancements become even slightly more complex, this approach results in a horribly unmaintainable mess of DOM manipulation, and an alternative approach is needed. That's when I prefer to write the entire thing in , but at that point nothing works anymore with NoScript.

Why is web development so annoying?

0.19: "We've removed all Native modules and plugged all XSS vectors, it's now impossible to talk with Javascript other than by using asynchronous ports!"
Me: "Oh yeah? I'll just run sed over the generated Javascript and patch in my own methods!"

I just figured out an alternative hack to upload files from , without relying ports or 'Native' code.

I now let Elm send a regular HTTP POST request, with the id of the file input in the request body. I then override XMLHttpRequest.prototype.send() with my own to intercept this body, grab the file from the DOM, and insert it into the request.

I'm not proud of myself, but it works.

Ew, upgrading to 0.19 is kinda painful; Mainly because I was using some hacks with 'Native' and 'effect' modules, both of which are now horribly (and, unsprisingly intentionally) broken.

And there's still no supported solution for file uploads. 😢

Ooh, 0.19 is finally out! 10 months later than I had expected, but no matter, I wasn't in any hurry. Looks like there's a bunch of nice improvements. I'll upgrade my code in the next few days and see how that works out in practice.

I have evaluated and experimented with and before deciding to stick with . I find that both PureScript and Haskell are vastly more powerful and superior languages, but it's the tooling, documentation and ecosystem (stability) that convinced me to use Elm. PureScript is married with NPM, GHCJS is a pain to get running.

Elm is 5 binaries and a few small libs with no other dependencies, and comes with a platform that has most of what you need. The output JS is smaller, too.

Minor gripe about functional DSLs for HTML: Please allow the type of "a piece of HTML" to contain any number of nodes. I've yet to see a function that cares whether it is being given exactly one node or any other number. 's Lucid does this right, but in I frequently have rewrite functions to accept a List of nodes, or insert additional containing nodes into the DOM.

I now have 75k of code, excluding dependencies. It compiles and minifies to 155k of Javascript, which compresses down to 39k. That's really not bad at all.

doesn't have an officially supported API to handle file uploads, and the alternatives are... not cute. Oh well, ugly hacks have become a specialty of mine. 😅

Static typing doesn't save me from my own stupidity.

Yesterday I was working on an autocomplete thing in , and while experimenting I connected the HTTP response to the same message as the onBlur event, because I just wanted the thing to compile.

Today I spent 30 minutes wondering why the onBlur event was triggering so often.

I just realized my new data validation module could solve all my issues with <-> data interchange. The validation schema can be used to derive Elm data types and generate code to do JSON encoding and decoding. The same schema can be used to coerce Perl data into the appropriate format for the JSON decoder.

I wonder if I should continue with this approach. It trades complexity for some DRY. And nobody uses Perl nowadays, so I'll be the only user of the necessary tooling. :blobunsure:

takes some getting used to at times. In my mind this function needs a (Show a, Eq a) typeclass constraint, but Elm doesn't mind a little type unsafety.

The image preload code turned out kinda ugly indeed, but the overal result is nonetheless pretty nice.

The gallery viewer at v3.vndb.org/v3 is now written in :blobwoah:

Source: g.blicky.net/vndb.git/tree/elm
And the rather ugly supporting JS: g.blicky.net/vndb.git/tree/sta

There doesn't seem to be an easy way to preload images in . This might get ugly. :oh_no:

Hmm, the tooling seems miss an "only download missing packages" command. I'm now running 'elm make --yes' from my Makefile, but that command fails when adding a new package to elm-package.json. I could add 'elm package install -y' before the 'elm make', but that'll hit the internet on every build. 🤔

niu.moe

Welcome to your niu world ! We are a cute and loving international community O(≧▽≦)O !