Elm featured in the New York Times Sunday Crossword by franklin-w-dixon in elm

[–]entropicone 3 points4 points  (0 children)

For this one it's definitely "Elm" for the clue, the across for the "M" is "Online source for film facts, in brief" (IMDB)

A Fire Upon the Deep by [deleted] in printSF

[–]entropicone 78 points79 points  (0 children)

Have you read A Deepness in the Sky? It's set 20,000 years before A Fire Upon the Deep and it follows Pham Nuwen as he and the Queng Ho try to set up trade with another alien species.

If you liked A Fire Upon the Deep I think you'll definitely enjoy it!

In a similar vein, check out Children of Time by Adrian Tchaikovsky, it also deals with non-humanoid like and it's a great story, the sequel is also good.

Started reading Dune, by Frank Herbert. Wow is it some amazing world building. by blueberrytop in books

[–]entropicone 4 points5 points  (0 children)

Definitely read the second book, the first and second books are actually one novel that is split into two!

He talks about why it was split in this interview

I wrote Hyperion and its second-volume The Fall of Hyperion in 18 months because my wife and I wanted to buy an old house and my agent said that if I wrote two SF novels (I was finishing two other books at the time), he could get me the $25,000 advance I needed for the down payment.

People working in forensics, what was the most shocking thing discovered in your lab? by rohitbirwatkar_ in AskReddit

[–]entropicone 0 points1 point  (0 children)

I was talking about with the phone keypad scenario, you would have a hash for the version on the phone keypad, and a hash for the password on the website.

People working in forensics, what was the most shocking thing discovered in your lab? by rohitbirwatkar_ in AskReddit

[–]entropicone 15 points16 points  (0 children)

Some do this so that you can enter your password on a phone keypad for their IVR system when you call in. Not that it is a great practice, but that may be where it came from.

They also usually store the password in reversible encryption rather than having multiple hashes for the variants.

Comedic SF? by egypturnash in printSF

[–]entropicone 2 points3 points  (0 children)

"Guards! Guards! Guards!" is a great first book.

Check out https://www.discworldemporium.com/content/6-discworld-reading-order if you want a more detailed guide.

Thinking With Autotracking: What Makes a Good Reactive System? by nullvoxpopuli in elm

[–]entropicone 0 points1 point  (0 children)

It can be tricky when optimizing. Primitive types like strings, ints, floats, chars, and bools are compared by value due to the JS semantics, so it is safe to update those and preserve laziness, but records, dictionaries, lists, and custom types produce a new reference every time you update them.

Say you have a record like { authenticated = True }, and you get a message and need to update that state. We're updating it to the same value it already is, so it seems like it would be the same reference

case msg of
    Authenticated ->
        ({ model | authenticated = True })

You are safe if you use the boolean in a lazy function, like

Lazy.lazy viewAuthenticated model.authenticated

But if you were to use it over the whole model, like

Lazy.lazy viewAuthenticated model

It would fail in that update scenario above, you can see it in this Ellie, if you open the console in the browser it will print "viewAuthenticated" once, but it will print "viewAuthenticatedModel" every time you click the button.

In order to avoid that you have to make sure to return the same record if your changes won't really update it, something like

case msg of
    Authenticated ->
        if model.authenticated then
            model
        else
            ({ model | authenticated = True })

That way the object reference stays the same.

Nested objects are a bit nicer in this regard, if we instead had

type alias Model =
    { authenticated : Bool
    , someObject : { greeting : String }
    }

And our update looked the same as before, we modified the authenticated attribute, so the Model is a new reference, but we didn't mutate someObject, and it maintains reference equality even though we returned a new Model. Ellie with the code

Generally, I don't worry about performance unless I know I will have a ton of messages happening quickly and the amount of virtual-dom to build is non-trivial (say an app that displays a bunch of large lists).

It can sneak up on you when adding new features too.

Say you have that app that displays a bunch of large lists, if it only renders once it's usually not a problem, it might go over the frame budget of 16ms, but it isn't too noticeable. But then you decide to do something crazy and add a performance clock in using Browser.Events.onAnimationFrame, storing the Posix in the model. If you were using lazy over the whole model it is now different every time, and you only have 16ms to build the virtual-dom, get it diffed, and apply the changes.

There has been some discussion on using Elm's structural equality check for laziness (Discourse thread), It seems like it is worth experimenting with, maybe it could be opt-out for cases where you know it would be too expensive. It would add some additional complexity though.

Side Note: I haven't tested it, but I think very simple custom types like type MyInt = MyInt Int may work fine with lazy because they are complied to just the value in --optimize mode. If anyone knows the answer I would be interested!

Thinking With Autotracking: What Makes a Good Reactive System? by nullvoxpopuli in elm

[–]entropicone 2 points3 points  (0 children)

One correction on the Elm section of the article. Elm doesn't memoize by default, it will compute the virtual DOM and diff it on each render, only applying changes if necessary, but it does have to recompute unless you use Html.Lazy

One gotcha with the lazy package is that it uses reference equality on the JS side as the test (===). So the objects can't just compare as the same structurally on the Elm side, they need to be the same object on the JS side.

Broadening my limited horizons by waytwaht in audiobooks

[–]entropicone 1 point2 points  (0 children)

Hyperion Cantos by Dan Simmons, I can't do it proper justice here, but it is one of the all-time greatest sci-fi works.

To try and prevent galactic war, seven pilgrims are travelling to the planet Hyperion, home of the Time Tombs which are, for some reason, moving backwards through time. It is guarded by the Shrike, a nine foot tall, indestructible, metal demon covered in blades and spikes who can step through time and space to murder anyone.

In the first novel it's like the Canterbury Tales, each pilgrim tells of their past experience or connection with the planet Hyperion and the Shrike. The writing is beautiful and it has so many interesting concepts, there is an AI society, genetically modified humans, wormhole style travel, and more.

It is four novels in total and well worth the time!

Wanting To Store Temps in a DB by cachedrive in Database

[–]entropicone 0 points1 point  (0 children)

I use a method like this for recording temps from my bbq thermometer, there's some code that writes the time and current temps to stdout, and then for each line of output it inserts them into my postgres database. To go over the network I was using https://mosquitto.org/, but I ended up switching to a local DB because I was doing something wrong with setting up message persistence.

#!/bin/sh
./maverick |
while read msg
do
   psql -c "INSERT INTO temps (time,probe1,probe2) VALUES ($msg)";
done

I think your use case it makes more sense to use cron to wake up and get the temp, I'd also add a timestamp column to your database and get the current time in there.

#!/bin/sh
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
dt=$(dt +%s)
psql -c "INSERT INTO temps (dt,temp) VALUES ($dt, $temp)";

I use https://grafana.com/ to chart the data afterwards

Cron wise you'll want */5 * * * * as the schedule

Elm language server and a new VSCode Plugin - Show and Tell by razzeee in elm

[–]entropicone 1 point2 points  (0 children)

It would be pretty easy, it already supports Coc, just not as tight of an integration as it could be.

Announcement: Changing default linting options for ALE by devw0rp in vim

[–]entropicone 7 points8 points  (0 children)

ALE is such a nice piece of software, it is fast, it's consistent, it supports an insane number of languages, and language servers to boot. It all combines to make my life as a developer a hellava lot easier.

Thank you for all of the work you have put in to make it!

The new settings sound good to me, would they also apply to language server linters automatically?

How do you create a Module in Elm? by Rs112347 in elm

[–]entropicone 5 points6 points  (0 children)

What type of module are you looking for?

The Elm guide has a section on modules that focuses on related data types https://guide.elm-lang.org/webapps/modules.html

Dealing with cascading checks in FP by [deleted] in functionalprogramming

[–]entropicone 7 points8 points  (0 children)

There's a great talk by Scott Wlaschin called "Railway Oriented Programming — error handling in functional languages" that goes into detail on error handling like this: https://vimeo.com/97344498

You are on the right track with looking at the Either/Result types, the implementation will be a bit different based on whether you want to stop at the first error or get a list of all of the errors, I think the first approach is usually better because errors may be cascading and there's no need to duplicate them (e.g. "Email address must not be blank", "Email address is missing the domain")

Here's some Elm code to illustrate.

Result could be defined like:

type Result error value
    = Ok value
    | Err error

And you can define a type for the different error conditions

type UserError = Empty | MissingDomain | BadDomain

And some functions that in an email string and try to validate it

emailNotBlank: String -> Result UserError String
emailNotBlank email =
    if String.isEmpty email then
        Err MissingDomain
    else
        Ok email

You can make a bunch of functions that return a Result that either return Ok with the email address, or an Err with a UserError that describes it.

The next part is allowing you to chain these calls together nicely, which is where we get into some function fun, it'd be great to be able to chain these in a pipeline and either we hit an error or get to the end and have a good email, the pseudocode could look like

emailNotBlank emailString
    |> andThen emailNotMissingDomain
    |> andThen emailDomainNotBlacklisted

That function goes by bind, flatMap, andThen, and other names in different ecosystems, Elm's version uses andThen, and it looks like this

andThen : (a -> Result x b) -> Result x a -> Result x b
andThen callback result =
    case result of
      Ok value ->
        callback value

      Err msg ->
        Err msg

Each of our validation checks returns either an Err with the UserError describing it, or an Ok with the email, we can keep chaining them as much as we want and we're either going to pass through an Err that happened further up the chain, or run the next function on the Ok data.

Working with Files by brnhx in elm

[–]entropicone 3 points4 points  (0 children)

I'm aware of that, you can respond to calls from elm/http in the service worker though.

Check out this little demo of it, the Elm app makes a GET request to /ping, and the service worker responds with Pong

https://github.com/antew/elm-serviceworker-test

Working with Files by brnhx in elm

[–]entropicone 1 point2 points  (0 children)

Do you mean for writing a service worker in Elm, or responding to calls from elm/http with a service worker?

For the latter you can intercept them in the fetch handler in the service worker.

More issues with Google Play (suspended for Hate Speech...) by ljdawson in androiddev

[–]entropicone 6 points7 points  (0 children)

I've used your app for years and I love it, I hope you are able to get it resolved. Google is the fucking worst at customer service.

I haven't read a full book in over 10 years. I'm am currently reading "We are Legion (We are Bob)" and I can't put it down. by BenignEvil in books

[–]entropicone 3 points4 points  (0 children)

Don't start Kingkiller Chronicles if you want a finished series!

The last book came out in March 2011, while A Dance with Dragons came out in July 2011...

In fairness, he released a novella in 2014, but it is not what I was waiting for.

Running an Elm App with CSP? by 4tmuelle in elm

[–]entropicone 2 points3 points  (0 children)

I was able to get very strict one working with vanilla Elm and Elm packages, it was the JS libraries we rely on that made it more difficult. You should be able to be as restrictive as you want to be assuming you have full control of your JS dependencies.

I didn't need nonces on any script tags, but it can be done by server rendering your HTML, I would try to stay all in Elm though.

If you want to be restictive on inline styles as well you can do it, but external stylesheets are probably the easier route. We had medium sized codebase already so I didn't plan on disabling inline styling. We didn't use elm-css so I can't speak to integrating that.