Lisplog

Blogging in Lisp

Search

Feed Aggregator Page 322

Rendered on Tue, 19 Feb 2019 08:01:50 GMT  newer latest older 

Making impossible state transitions impossible (Oslo Elm Day question)

via Elm Discourse - Latest posts by @perty Per Lundholm on Tue, 19 Feb 2019 07:49:02 GMT

I’ll take that as advice. State machine is a simple and powerful way to model.

Working with data: statistics & visualization

via Elm Discourse - Latest posts by @jxxcarlson James Carlson on Tue, 19 Feb 2019 02:19:16 GMT

Following @Jess_Bromley 's suggestion above, I have added support for error bars in the new module ErrorBars. See the latest version of jxxcarlson/elm-stat (3.0). What other missing features should I be working on?

Working with data: statistics & visualization

via Elm Discourse - Latest posts by @jxxcarlson James Carlson on Tue, 19 Feb 2019 02:16:08 GMT

Thanks very much! Indeed, I have been looking at gampleman’s elm-visualization and plan to adopt it in the very near future,

Cross-browser compatibility fix for File.Select.file(s) in elm/file

via Elm Discourse - Latest posts by @system system on Mon, 18 Feb 2019 23:46:47 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Making impossible state transitions impossible (Oslo Elm Day question)

via Elm Discourse - Latest posts by @rupert Rupert Smith on Mon, 18 Feb 2019 22:01:28 GMT

I have found a use for it sometimes where I designed a state machine to describe how a UI should behave before writing any code. I tend to do this as a series of pen and paper sketches; quick iterations. It can then be nice to code that up as a pure state machine, before tackling the bigger job of writing the view.

Any resources for json-schema or swagger specs?

via Elm Discourse - Latest posts by @system system on Mon, 18 Feb 2019 14:19:42 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Http unit tests. How?

via Elm Discourse - Latest posts by @system system on Mon, 18 Feb 2019 12:12:23 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Simplify list compare logic

via Elm Discourse - Latest posts by @Libbum on Mon, 18 Feb 2019 10:12:22 GMT

Hah! Of course it is! Sorry, I was looking for complexity where there shouldn’t have been.

Simplify list compare logic

via Elm Discourse - Latest posts by @dmy on Mon, 18 Feb 2019 10:01:07 GMT

> secret = [3,4,5,1,3,6]
[3,4,5,1,3,6]
    : List number
> challenge = [3,4,5,1,3,6]
[3,4,5,1,3,6]
    : List number
> (secret == challenge)
True : Bool

> challenge = [3,4,5,1,3,5]
[3,4,5,1,3,5]
    : List number
> (secret == challenge)
False : Bool

Or did I miss something?

(Note that parentheses are needed because of a bug in elm repl if I remember correctly)

Simplify list compare logic

via Elm Discourse - Latest posts by @Libbum on Mon, 18 Feb 2019 09:53:46 GMT

I’m sure this could be done better, so just wondering how you would compare all values in two lists, returning true if all values are the same.

My current solution:

secret = [3,4,5,1,3,6]
challenge = [3,4,5,1,3,6]

List.map2 (==) secret challenge |> List.all (\c -> c == True)
--> True

I’d like to just use the core, but examples using List.Extra or something else would be interesting for my education. Specifically, I think this may be a time I could use the >> operator, but I have trouble conceptualising its use.

Weird not & modBy result

via Elm Discourse - Latest posts by @dmy on Mon, 18 Feb 2019 09:45:38 GMT

This is a known bug that will be fixed in the next release:

One Elm "app" per page

via Elm Discourse - Latest posts by @nikolaipaul Nikolai Paul on Mon, 18 Feb 2019 09:40:33 GMT

Another advantage of this approach is the ability to reuse the localization facility of your backend framework.

Gilded Rose Kata Refactoring — Part 1

via The Oozou Blog - Medium by Alireza Bashiri on Mon, 18 Feb 2019 09:40:29 GMT

Gilded Rose Kata Refactoring — Part 1

Here’s a well-known Kata called Gilded Rose which has a flog complexity of 45 and almost 12 duplicate method calls and is a great example for refactoring so let’s hop into it.

How we got here?!

Dom: You think you can refactor this?
Ali: I’m all for it
Dom: Are you sure?

So how we should approach this?

Luckily the author wrote some tests so let’s see how tick method works

Normal behavior

From this test we’ve found out that GildedRose has a normal behavior. Let’s make normal tests fail:

By just returning when name is “normal”
Normal tests are failing

Now extract a new method called normal_tick and add just enough to make normal tests pass again:

Now we’re green

Now we’ve written code that even we at this moment don’t understand, but now we’re green so we can refactor.

Before/After refactoring
We’re still green

In the next post we will refactor Gilded Rose brie behavior which is another if branch that checks against “Aged Brie” in tick method.

Thanks for reading and hope you’ve enjoyed your time.


Gilded Rose Kata Refactoring — Part 1 was originally published in The Oozou Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

Weird not & modBy result

via Elm Discourse - Latest posts by @vgrigoriu Victor Grigoriu on Mon, 18 Feb 2019 07:38:45 GMT

So I’m working through the Elm track on Exercism using Elm 0.19. I encountered the strangest thing while solving the Leap exercise.

I have the following functions, which I expect to be equivalent:

f1 : Int -> Bool
f1 year =
    modBy 3 year /= 0

f2 : Int -> Bool
f2 year =
    not (modBy 3 year == 0)

However, this test shows that they’re not:

Expect.equal (Leap.f1 1) (Leap.f2 1)

The output is:

True
╷
│ Expect.equal
╵
1

I don’t even know what that 1 is doing there, since both functions return Bool?

I’m sure I’m missing something obvious, can someone explain the behaviour I’m seeing?

Thanks!

One Elm "app" per page

via Elm Discourse - Latest posts by @Sebastian Sebastian on Mon, 18 Feb 2019 00:13:49 GMT

This is fine, you will need to create different apps for each page. But you can compile them all at the same time in one big bundle. Something like elm make App1.elm App2.elm.

One Elm "app" per page

via Elm Discourse - Latest posts by @francescortiz Francesc Ortiz on Sun, 17 Feb 2019 22:47:19 GMT

You have the option of creating independent files for each page or you can create a single file with all the pages.

If you decide to have a single page app, you could check the URL as a normal SPA, but adapting the parser to process the actual URL and not the #hash part.

Many messages causes slow rendering

via Elm Discourse - Latest posts by @francescortiz Francesc Ortiz on Sun, 17 Feb 2019 22:36:36 GMT

Check this ellie example:

https://ellie-app.com/4Ls2kmFnyNva1

One Elm "app" per page

via Elm Discourse - Latest posts by @pdamoc Peter Damoc on Sun, 17 Feb 2019 21:04:59 GMT

I don’t see why that would be more difficult to maintain. With a SPA, you have only one entry point: Main.elm. Implementing one Elm app per page would mean that you just replace Main.elm with PageOne.elm, PageTwo.elm etc.

The common stuff stays common.

You have the option of creating independent files for each page or you can create a single file with all the pages.

How to use elm/file?

via Elm Discourse - Latest posts by @AlanQ on Sun, 17 Feb 2019 20:51:39 GMT

Thank you, @ivadzy. It’s good to see a variety of approaches.

Very handy to have a file-drop example, especially to note preventDefaultOn "drop" — an interesting reference regarding this here Is call to preventDefault() really necessary on drop event?.

Didn’t think I’d need drag’n’drop but it’s a common way to load files in desktop applications so a good option to offer users.

One Elm "app" per page

via Elm Discourse - Latest posts by @negcx Kyle Johnson on Sun, 17 Feb 2019 20:47:59 GMT

I am interested in potentially using Elm to render my entire frontend, but not in an SPA-style. Rather, I am interested in the approach of rendering a template which contains all of the data and then passing the data to my Elm app for each page. (i.e. routing, core data fetching, etc is done server-side)

My basic question is, do I need to somehow create N elm apps and compile them all separately, or what is the best approach to this? That seems like it would be very difficult to maintain.

 newer latest older