Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sedro posted:

If we only included pure languages this would be a haskell thread

Sorry but Haskel does output, which is a side effect soooo

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



fart simpson posted:

A guy did a good talk at Strange Loop that I just watched where he gives a really high level description of what it's like to actually use Elm. I liked the talk:
https://www.youtube.com/watch?v=FV0DXNB94NE

The picture of O'Reilly's JavaScript next to java script: The Good Parts made me lol

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm loving around in Elm and trying to do the exercises in http://elm-lang.org/examples/binary-tree

For #2 I tried to do
code:
flatten : Tree a -> List a
flatten tree = 
    case tree of
      Empty -> []
      Node value left right -> 
          flatten left :: value :: flatten right
But I'm getting an infinite type error for left in the second case branch (I guess you'd call it? as in Node value left right ->) and have no idea how to apply the advice in https://github.com/elm-lang/elm-compiler/blob/0.16.0/hints/infinite-type.md because I'm an f-lang noob. What did I do wrong?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Yep, that's it. I thought I was being all clever there by avoiding implicitly creating a bunch of basically-useless single-element lists.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



VikingofRock posted:

I think that would get compiled away anyways, but if not I think this would work:

code:
flatten : Tree a -> List a
flatten tree = 
    case tree of
      Empty -> []
      Node value left right -> 
          flatten left ++ (value :: flatten right)
edit: You might not even need the parens, depending on operator precedence.

Yep, that works without the parens.

Meantime, my dumbass attempts at writing fold are crashing their compiler service :(

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm OK if Elm doesn't have all the bells and whistles all the cool modern f-langs have because I'm just hoping to pick it up as a sane, clean way to make web front-ends and hopefully finally get my head around some functional syntax and concepts via a practical tool that might actually make stuff I want to do easier.

That presentation was great.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Am I just super bad at this or am I finding the compiler bugs? Both?

code:
fold : (a -> b -> b) -> b -> Tree a -> b
fold func acc tree = 
    case tree of
      Empty -> acc
      Node value left right -> 
          --(func value (fold func acc left)) `func` (fold acc func right) -- crashes the compiler
        let 
          partial : Tree a -> b
          partial = (fold func acc)
        in
          (func value (partial left)) `func` (partial right)
code:
The left argument of `func` is causing a type mismatch.

101|           (func value (partial left)) `func` (partial right)
`func` is expecting the left argument to be a:

    a

But the left argument is:

    a

Hint: A type annotation is clashing with itself or with a sub-annotation. This
can be particularly tricky, so read more about it.
<[url]https://github.com/elm-lang/elm-compiler/blob/0.16.0/hints/type-annotations.md[/url]>
Uh, ok? :confused:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Bognar posted:

I think you want your final let..in clause to be something like:

code:
let
  leftFold = fold func acc left
  acc = func value leftFold
in
  fold func acc right
This folds the left sub-tree using acc, generates a new acc from the left-folded sub-tree and the current node's value, then passes that new acc down into the fold for the right sub-tree.

Which I can rewrite to simply fold func (func value (fold func acc left)) right and now I feel like an idiot for not seeing that immediately, but I guess that means I'm making progress.

E: oh here's a shocker: it's way easier to look up type declarations in the docs than to try to infer them like I was doing ugh jfc

Munkeymon fucked around with this message at 22:39 on Dec 31, 2015

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



The 0.17 installer was flagged as Win32/Fathale.B!plock by Windows Defender, but only after I ran it. Hope it's a false positive :ohdear:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



https://github.com/ElmCast/elm-node exists, but I imagine it'll be 'experimental' forever because there are already decent server-side (functional) languages.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



xtal posted:

HTML, CSS and as little JavaScript as possible. If you're using React you've already lost the battle

If your UI is trivial enough for that advice to work, I recommend giving up and using one of the drag-and-drop WYSIWYG site builder things because you don't have any problems they can't handle

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



xtal posted:

99.999% of UIs are that trivial and if you think you're the exception you're probably wrong but knock yourself out

I don't entirely disagree - I think the percentage is somewhat lower depending on how you count, but the people who pay me sure do.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



kujeger posted:

to be fair, ten minutes on the internet is enough to drive most anyone to contempt

Because most sites are jenga stacks of Wordpress plugins and many if not most 'web developers' are idiot shitmonkeys who only know how to copy+paste poo poo from SO until something sort of works, but there are decent, well-made sites out there.

xtal posted:

http://www.idris-lang.org/towards-version-1-0/

*starts countdown on uninstalling ghc*


Ten years in this case. gently caress the web

quote:

A Language with Dependent Types

Titillating stuff

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



the talent deficit posted:

i think it's only a matter of time before you see clients that effectively just make rpc calls to a backend service. whether this is negotiated via an sdk that uses graphql/rest or just uses something like gRPC or thrift over http2 i think application developers will stop having to care about the details of how their app talks to the server

on the server side i think it's inevitable that apis reuseable by multiple clients will replace server generated html completely. for web browsers i expect turning javascript off will soon be unthinkable

Just to pick a nit, I don't think server-side rendering is going away anytime soon because people are paranoid about getting something to display ASAP and I don't think those people are going to trust networks to deliver their front-end code fast enough. Granted, this'll probably take the form of running a headless client against the API and shoving what it renders into a cache, so, yeah, agreed that stuff like Django and Rails are going away.

xtal posted:

That's pretty much the status quo, as someone who uses w3m and surf with JavaScript off. Someone should have seen this horror show coming.

Yes, this world where there's a viable solution for a write-once-run-everywhere client UI that can be made to look like not-poo poo, is safely isolated from other programs and is Good Enough for most requirements is truly the stuff of nightmares.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



xtal posted:

If you think the web is good enough I don't even know where to begin with that.

If you're doing something a browser can't do well enough for 99% of users then yeah sure it's real bad. Otherwise, it's a featureful, near-universal UI toolkit that, like any other complicated thing, happens to have some sharp edges and only runs a janky-assed language under the hood that you never have to write a line of if you don't want to.

Also many people misuse the poo poo out of it in various terrible ways, so there's that.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sedro posted:

They're still using it

But are they still making new things with it or just maintaining things they can't bear to replace

  • Locked thread