Re: [elm-discuss] Distinguishing HTTP error codes

2017-12-03 Thread Peter Damoc
Are you able to confirm in the developer console or Postman or some other
tool that you are actually getting a 401 from the server?

I'm getting 400 and 401 just fine from my servers and Elm is encoding them
just fine as a BadStatus.



On Sun, Dec 3, 2017 at 5:36 AM, Michal Blazejczyk <
michal.blazejc...@gmail.com> wrote:

> Hi all,
>
> I'm just beginning to get into Elm, and I encountered an issue.  My Elm
> app is making a POST request (Http.post) and when the server returns 400 or
> 401, I get NetworkError instead of BadStatus which means that I cannot
> distinguish between error codes.
>
> Looking at Javascript generated by the Elm compiler, I see:
>
> function toTask(request, maybeProgress)
> {
>   // ...
>   xhr.addEventListener('error', function() {
> callback(_elm_lang$core$Native_Scheduler.fail({ ctor: 'NetworkError'
> }));
>   });
>   xhr.addEventListener('timeout', function() {
> callback(_elm_lang$core$Native_Scheduler.fail({ ctor: 'Timeout' }));
>   });
>   xhr.addEventListener('load', function() {
> callback(handleResponse(xhr, request.expect.responseToResult));
>   });
>   // ...
> }
>
>
> For 400 and 401 responses, the browser triggers the listener for 'error'.
> Is there a way to have Elm generate a BadStatus in this case?
>
> Best,
> Michal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] How to enforce Elm to recreate HTML tags instead of reusing existing tags?

2017-11-27 Thread Peter Damoc
Use Html.Keyed for managing the troublesome kids.

Here is your example adapted based on your feedback that it is the age
field that's the problem.
https://ellie-app.com/czbx9WRyDa1/0



On Mon, Nov 27, 2017 at 7:12 PM, Kadzuya OKAMOTO 
wrote:

> Here is an example app to explain this problem.
> https://ellie-app.com/c5X3fGFPha1/1
>
> In this example, a popup window flashes unexpectedly when "Tab B" is
> clicked.
> The reason why this occurs, I guess, is bellow.
>
> * "Tab B" is clicked
> * Elm tries to reuse HTML tag (in this case the tag of the age field).
> * It causes `addAttribute("aria-hidden", "true")` on the tag
> * CSS transition fires because `aria-hidden` attribute was changed
>
> To prevent this unexpected phenomenon, I'm looking for a way to prohibit
> Elm to reuse existing tags.
> Is any workaround for this?
> Or is my hypothesis above wrong?
>
> I believe this is a usual requirement especially when we use
> `elm-lang/navigation` package to realize SPA routing.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Expanding competence

2017-11-07 Thread Peter Damoc
Hi David,

I  think you already know everything you need to know.
Just attempt to do it and if you get into trouble the community will assist
you.

For a multi-user app you also need a backend and since Elm does not have an
official backend story, you will need to switch to another language.
I highly recommend the RealWorld/Conduit project.
https://github.com/gothinkster/realworld

You have there examples from a lot of languages for both the backend and
the frontend.
The Elm frontend example is the best guide for implementing a full SPA in
Elm.


On Wed, Nov 8, 2017 at 1:54 AM, David Legard  wrote:

> I have been working with Elm regularly since about 0.13, so I'm fairly
> competent up to and including JSON, Cmd, Sub, JS interop and topics like
> that. I have built some fairly detailed apps with those technologies
> included. I focus on educational software.
>
> What are the minimum extra skills I need to learn to create true
> multi-user apps, with log-in forms, authentication, and personalised
> student learning records?
>
> Does this require a considerable leap in what I have to know, or are there
> relatively painless ways of getting to this next level?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] What build system do you prefer for Elm?

2017-10-31 Thread Peter Damoc
Consider using npm as a build system
https://css-tricks.com/why-npm-scripts/

The main advantage is that you can control everything easier.
The main disadvantage I guess is that it might get complicated for complex
scenarios.




On Tue, Oct 31, 2017 at 4:18 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> I've been using grunt up until now. Looking into webpack at the moment as
> a few github projects I've been looking at use it.
>
> Anyone got any thoughts on the advantages/disadvantages of the various
> possibility wrt Elm?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] The NumPy for Elm

2017-10-31 Thread Peter Damoc
Hi Fran,

I would be interested in seeing performance benchmarks agains NumPy.
I'm expecting NumElm to be worse but I'm curious how much worse it is. :)

In any case, congrats for creating this!



On Tue, Oct 31, 2017 at 2:32 PM, Francisco Ramos 
wrote:

> Today I'm releasing NumElm, another small contribution to the Open Source,
> Frontend and Elm community. NumElm is inspired by NumPy, the fundamental
> package for scientific computing with Python. NumElm is the first step in
> this ambitious idea of mine of building a Machine Learning package for Elm.
> Still a long way to go, but I'm full of enthusiasm. I'm convinced about the
> potential of both worlds together, Elm language and Machine Learning.
>
> https://github.com/jscriptcoder/numelm
>
> Please, any feedback would be highly appreciated.
>
> Fran
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Is Elm going stale?

2017-10-27 Thread Peter Damoc
On Thu, Oct 26, 2017 at 8:50 PM, Brian Hicks  wrote:
>
> Even if the language were not being actively developed (which it is) the
> community is thriving and I would hope makes the investment in using the
> language worthwhile. :)
>

If one learns a language for some toy project is one thing.
If one evaluates a language for potential use in production code, the
requirements are very different.

Concerns about a language going stale sound to me as fitting the second
category.




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Is Elm going stale?

2017-10-27 Thread Peter Damoc
On Thu, Oct 26, 2017 at 8:11 PM, LondonTokyo 
wrote:

> Its now been a year since the last Elm release, and there has been no
> updates in Github for 3 months, as far as I can see.
>

Last update in the dev branch of the core was about an hour ago. The master
branch does not show the actual story of current development.


> Seems to me that Elm is danger of becoming abandoned, and is going stale.
> It certainly does not seem like it is something worth investing any time
> on, nor does it seem safe to write any application in Elm anymore.
>

Elm is in no danger of being abandoned because of the gigantic investment
made by NoRedInk. They have a huge Elm codebase and as long as this company
exists, Elm should be fine.


> But where is it heading? What's the roadmap? Why are there no / little
> communication / publication from the maintainer(s)?
>

There is no actual roadmap and very little is know about the direction of
the language. In July 0.19 looked imminent, now I would not put money on a
bet that we will see 0.19 this year.

I think the best way to approach Elm is to consider it feature complete
now.
If what it currently offers is enough for you, use it.
If you hope to get some missing functionality, I think it is safer to chose
something else.
If you want to use it in a different domain than the one currently
supported, again... it is safer to go with something else.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: ELM = JAVASCRIPT REINVENTED (PART 1)

2017-10-25 Thread Peter Damoc
Reality is prickly-goo and gooey-prickles
.

Elm sins by seeing reality too much from a prickly point of view.
You can call this opinionated but if it is taken to an extreme, you get the
symptoms typical to a prickly system, the main one being the stifling of
creativity.
Creative people are gooey and they don't thrive in an environment that is
too prickly.

Also, businesses need gooey stuff because they deal with reality not with
some abstract world of ideas.


On Wed, Oct 25, 2017 at 12:19 PM, John Orford  wrote:

> I think Elm is a very opinionated language - which lends itself to love &
> hate : ) Which is a good thing - languages in which you can do anything and
> everything are guey slimey things...
>
> On Tue, 24 Oct 2017 at 18:36 Charles Scalfani  wrote:
>
>> Back in the day when Java was all the rage, I used to ask 2 interview
>> questions of developers:
>>
>>
>>1. What do you love about Java?
>>2. What do you hate about Java?
>>
>> I never cared what the answer was to #1. It turns out that they simply
>> listed all of the things that people who promoted Java mentioned,
>> write-once-run-anywhere, etc.
>>
>> It was #2 that I was really interested in. Many developers couldn't think
>> of a single thing. That told me that they didn't know Java. At the time, I
>> could've talked for an hour about all the things that were wrong with Java
>> (and still are). Why? Because I really knew the language. And familiarity
>> breeds contempt.
>>
>> This article feels like the answer to #1 by someone who really doesn't
>> know the language yet or at least hasn't built anything real or large with
>> it.
>>
>> Don't get me wrong I love Elm but it's not perfect (no language is).
>>
>> I'd hope that your articles include the good, bad and the ugly. By doing
>> so, you will help more people understand if Elm is right for them in a
>> balanced way.
>>
>>
>>
>> On Monday, October 23, 2017 at 11:02:11 AM UTC-7,
>> tfr...@imaginarycloud.com wrote:
>>>
>>>
>>> Hi,
>>>
>>> I'm a developer and founder of an agency specialised in digital product
>>> development.
>>>
>>> This summer we've decided to do some experimentation with Elm and we'll
>>> be summarising the findings in a series of two blogposts.
>>>
>>> Here is the first one. Comments are welcome.
>>>
>>> https://www.imaginarycloud.com/blog/elm-javascript-reinvente
>>> d-1-overview/
>>>
>>> Best,
>>>   TF
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm Logo vs Dynegy Logo

2017-09-15 Thread Peter Damoc
The Elm logo is a tangram .

I guess there are multiple businesses that either use it or used it. :)






On Fri, Sep 15, 2017 at 5:07 PM, David Zwerdling  wrote:

> This is probably OT, but can anyone talk about the fact that the Dynegy
>  logo looks identical to the Elm
> logo flipped and color corrected?
>
> Just curious.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm with one message

2017-09-05 Thread Peter Damoc
On Tue, Sep 5, 2017 at 10:02 AM, Vlad GURDIGA  wrote:

> In my app I have a large data entry form where initial fields determine
> which subsequent fields will be. It’s my understanding that every change to
> the model should be its own message. So far I have 50 fields in total (and
> there will probably be more) — does this mean that I need to have 50 things
> in my Msg? Or am I seeing it wrong? 邏
>
> Yes, you need to handle all 50 things in your Msg but you don't need to
have all 50 tags in the main Msg.

You can handle things in chunks.
Here is the Forms example altered to show one way to approach this:
https://ellie-app.com/4dhSNYfnrqya1/0

Here is another way to structure that code:
https://ellie-app.com/4dhSNYfnrqya1/1

And yet another way to structure it:
https://ellie-app.com/4dhSNYfnrqya1/3

What might be appropriate to do in your case depends on the shape of the
data. If the data can be split in smaller records that make sense maybe you
should split it.
If the data cannot be split and just needs to be one large record, then
maybe you can split just the updates in some manner that makes sense to you
and keep passing the same big record to all the update functions (second
link from above)

Needless to say that what you have above is only one section extracted.
With multiple sections you will just have one root Msg for each section and
update functions for each section.

-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Elm as templating engine

2017-09-04 Thread Peter Damoc
On Sun, Sep 3, 2017 at 11:07 AM, Birowsky  wrote:

> Unfortunately, it just adds `=""`. You can't see it in the dev tools
> because the browser strips it away.
>

Fortunately that is OK as it is implicitly equivalent to what you want:
http://w3c.github.io/html/infrastructure.html#sec-boolean-attributes
(see the first Note of the section)





-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm with one message

2017-09-01 Thread Peter Damoc
On Fri, Sep 1, 2017 at 9:38 AM, Vlad GURDIGA  wrote:

> Oh wow! This looks super cool! 邏
>
> …and it seems this would also cover for the issue that Peter mentioned
> :
> this gives me the ability to have a real onClick callback without
> pre-computing the expected-after-click state! 鸞 — Right Peter? 樂
>

As far as I understand things, this breaks the debugger because instead of
data, the messages contain functions.
The recommendation is to keep Models and Msg as pure data.




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Javascript interop width timing

2017-08-31 Thread Peter Damoc
Here is the watch example modified to have an effect in a place of the DOM
that's outside of Elm's control:
https://ellie-app.com/4b3rFVGCK32a1/0



On Wed, Aug 30, 2017 at 10:57 PM,  wrote:

> Hello guys,
> I'm involved in developing a interactive animation for children.
>
> I'm wondering if it is possible to control dom elements properties (build
> with Tumult Hype, specifically the position of that elements) via
> javascript ports on a timing base, like the watch hands of the example in
> elm-guide.
>
> If yes, where please can I find a skeleton suitable for this purpose?
>
> Many thanks,
> Rosario
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm with one message

2017-08-27 Thread Peter Damoc
On Sun, Aug 27, 2017 at 11:15 AM, Vlad GURDIGA  wrote:
>
> You basically have to computer all the possible future states of the app.
>>
>
> Not sure what you mean here. Could you please expand, or maybe point to an
> example in the code? 樂
>

Let's simply the problem space and imagine that you have 3 buttons that
when clicked do some serious computation on the model.

With a traditional approach you have the message sent by one of the buttons
and the specific computation done in response to the message.

With this approach, you would have to compute all 3 heavy computation and
send the new state with the message.  If your main message is:

type Msg
= Update Model

then the 3 messages you will have to use on `onClick` would be equivalent
to:

div []
[ button [onClick (Update (doTheUpdateForMessageOne oldModel))] [text
"Do First Thing"]
, button [onClick (Update (doTheUpdateForMessageTwo oldModel))] [text
"Do Second Thing"]
, button [onClick (Update (doTheUpdateForMessageThree oldModel))] [text
"Do Third Thing"]
]

Or, more realistically, inside a child component with its own `update`,
have something like:

view onUpdate model =
let
toMsg msg = onUpdate (update msg model)
in
div []
[ button [onClick (toMsg First)] [text "Do First Thing"]
, button [onClick (toMsg Second)] [text "Do Second Thing"]
, button [onClick (toMsg Third)] [text "Do Third Thing"]
]

this means that by the time the view is rendered, all 3 future states of
the that component have been computed.
This is not a big issue if computing all future states is trivial (e.g. one
toggle state of some drawer) so it's fine for small widgets but if you
scale this to the level of the entire app, you might run into performance
issues.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm with one message

2017-08-24 Thread Peter Damoc
On of the key recommendations of Elm Architecture is to have your messages
be just data.

Your approach is somewhat similar to the approach of elm-sortable-table
(except for the Cmds and Subs).

Without  using Cmds and/or Subs it is an interesting approach if you use it
for managing very small bits of state (the open/close status of a dropdown)
but I'm afraid that it might bring performance problems if you use it for
the entirety of the app.
You basically have to computer all the possible future states of the app.


On Thu, Aug 24, 2017 at 10:10 AM, Vlad GURDIGA  wrote:

> Hey Elm-guys and Elm-gals! 
>
> I have this toy-project
> 
> where I’m getting my feet wet with Elm, and I’ve found an approach to
> compose view function that’s a bit different than what The Elm Architecture
> recommends. 邏
>
> Because I found message transformation (mapping
> )
> between nested components to be counterintuitive, I left out messages, for
> the most part. I only have one
> 
> for the whole app: 
>
> type Msg
> = Update Model (Cmd Msg) (Sub Msg)
>
> update : Msg -> Model -> ( Model, Cmd Msg )update msg model =
> case msg of
> Update model cmd sub ->
> ( { model | subscription = sub }, cmd )
>
>
> Only the top component references it
> ,
> and from then on I use callback-style functions
> 
> for wiring up the nested components:
>
> view : Dosar -> (Dosar -> Cmd msg -> Sub msg -> msg) -> Html msgview (Dosar 
> data) callback =
> let
> c data =
> callback (Dosar data)
> in
> div []
> [ h1 [] [ text "Dosar nou" ]
> , Temei.view data.temei (\v -> c { data | temei = v })
> , DocumentExecutoriu.view data.documentExecutoriu (\v -> c { data 
> | documentExecutoriu = v } Cmd.none Sub.none)
> , Actiune.view data.actiune (\v -> c { data | actiune = v })
> ]
>
>
> and also for event handlers
> 
> :
>
> unlabeledTextField : String -> (String -> msg) -> List (Html 
> msg)unlabeledTextField defaultValue callback =
> [ input
> [ value defaultValue
> , onInput callback
> ]
> []
> ]
>
>
> It seems to work well so far, and coming from JS I find this style a bit
> more familiar conceptually: I only have functions and values. 邏
>
> I am at about 184K of Elm now, and I’m wondering if anyone else have tried
> to do it this way and maybe found some gotchas that I should be aware of.
> In particular, with regards to how the code compiles to JS and maybe other
> Elm’s inner workings. 樂
>
> Cheers! 鸞
>
> (NOTE: If you want to browse the code, please use this revision:
> https://github.com/gurdiga/xo.elm/tree/9fe9bd1. After that I’m bringing
> in elm-mdl ,
> and the code will probably get too noisy for the purpose of this
> conversation. )
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] More pattern matching

2017-08-22 Thread Peter Damoc
I don't know about elegant but one way to implement something like fizzBuzz
would be:
https://ellie-app.com/469wMYcvrZ3a1/0

Of course, this assumes that you have a lot of patterns and not the 4 in
fizzBuzz

If evaluating all the branches is too expensive you can use functions like
this:
https://ellie-app.com/469wMYcvrZ3a1/1




On Tue, Aug 22, 2017 at 3:46 PM, David Legard  wrote:

> Does Elm have anything between an *if-then-else* flow control and* case* ?
>
> My use case is, I need to parse a string in various ways to decide which
> Analysis ADT to assign to the string.
>
> Thus
>
> sconvert : String -> Analysis
> sconvert s =
>  if s=="all" then AllDays
>  else if s=="unplayed" then Unplayed
>  else if String.startsWith "onday" s then OnDay (secondBit s)
>  else if String.contains "totz:" s then Totz (secondBit s)
>  else Unknown
>
>
> There are about 30 different branches in my app, and it's convenient to
> keep them together.
>
> I can't use a case expression here, so I guess what I'm looking for is
> something like F#'s match expression, where you can add conditions using
> the when modifier. (code written as if the function existed in Elm
>
> fizzBuzz : Int -> String
> fizzBuzz x =
> match x with
> | i when i % 15 = 0 ->  "fizzbuzz"
> | i when i % 3 = 0 -> "fizz"
> | i when i % 5 = 0 ->  "buzz"
> | i  -> toString(i)
>
> What would be an elegant way to implement the fizzBuzz function in Elm?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Embedding the same view multiple times on a page

2017-08-15 Thread Peter Damoc
On Tue, Aug 15, 2017 at 11:21 PM, Anthony Naddeo 
wrote:

> Assuming I get that to work, what does embed actually do? Is each instance
> totally isolated? Does the elm runtime bootstrap itself each time? To share
> state, we'll have to use ports?
>

To my understanding, each instance is isolated.
I don't think there is a way to actually share state but you can keep the
state in various embeds synchronized by using ports.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Json file size

2017-08-11 Thread Peter Damoc
Use the dictionary as a JS service.

You can load the dictionary in JS and use ports to interrogate it.
https://ellie-app.com/3Z8hSkXxxBGa1/0

If you like to live dangerously you can also use Kernel code to interrogate
the JS dictionary datastructure synchronously.
Since the dictionary is fixed, the purity of the function is maintained and
this falls into one of those extremely rare use cases where one drops to JS
for performance reasons.




On Fri, Aug 11, 2017 at 5:32 AM, David Legard  wrote:

> I have been porting a language translation engine from HTML/JS to Elm, and
> it was easy to implement.
>
> The problem is that the dictionary contains 15,000 word pairs.
>
> I can't include those items as Elm files (since Elm-make runs out of
> memory), so I decided to put them in a JSON file and import that.
>
> It works when I load the application, but as soon as I start interacting
> with the app, the console logs the error:
>
> Main.elm:1381 Uncaught RangeError: Maximum call stack size exceeded
> at Object.cmp (Main.elm:1381)
> at Function.compare [as func] (Main.elm:1162)
> at A2 (Main.elm:92)
> at Function.func (Main.elm:4598)
> at A2 (Main.elm:92)
> at Main.elm:8952
> at Main.elm:16
> at A2 (Main.elm:93)
> at Function.func (Main.elm:5075)
> at A2 (Main.elm:92)
>
> Does anyone have any idea how I can circumvent this problem? Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm `reusable views`

2017-08-03 Thread Peter Damoc
Indeed, adding a ResizeObserver polyfill allows for the expected behavior:
https://ellie-app.com/3VFHVxMsW2ya1/1


On Thu, Aug 3, 2017 at 7:18 PM, Mark Hamburg <mhamburg...@gmail.com> wrote:

> We watch for resizing using some resize observation JavaScript code —
> search on ResizeObserver and you can find a number of hits — and feed the
> values back through a port tagged with the size of the observed entity.
> Attaching the observer in a virtual DOM is an interesting problem because
> elements can come in and out of existence based on what happens in the view
> function. Our solution to that was to mark observed elements with a class
> and use that to trigger an insanely fast animation and set up an observer
> to watch for the notification for when that animation runs. This is the
> sort of thing that leads to me saying "I hate the web."
>
> Mark
>
> On Thu, Aug 3, 2017 at 3:53 AM Peter Damoc <pda...@gmail.com> wrote:
>
>> You could try to use MutationObservers to ferry that information in Elm:
>> https://ellie-app.com/3VFHVxMsW2ya1/0
>>
>> Unfortunately, I don't know enough about them to provide a solution that
>> would actually monitors their resizing but maybe someone else could.
>>
>>
>>
>>
>> On Thu, Aug 3, 2017 at 11:43 AM, enetsee <mthomas...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have been trying to create a `resuable view` following the structure
>>> outlined in evanczs `elm-sortable-table`
>>> <https://github.com/evancz/elm-sortable-table/> and other examples,
>>> including:
>>>
>>>- abadi199s `datetimepicker`
>>><https://abadi199.github.io/datetimepicker/>
>>>- thebriticans `elm-autocomplete`
>>><https://github.com/thebritican/elm-autocomplete>
>>>
>>> I was attempting the reproduce the range slider from Palantir's
>>> BlueprintJS component library (example here
>>> <http://blueprintjs.com/docs/#core/components/sliders.range-slider>).
>>> My Elm version is here <https://github.com/enetsee/rangeslider>, with a
>>> live version in Ellie here <https://embed.ellie-app.com/3twhtJfZNvya1/0>
>>> .
>>>
>>> The Elm version extends the original by allowing the user to specify the
>>> scale that should be used. The live demo shows both a linear and
>>> logarithmic scale; the latter is particularly useful when asking users to
>>> select values which have a heavily skewed distribution (common in finance
>>> and insurance).
>>>
>>> The main limitation of the Elm version compared with the original is
>>> having to specify a fixed width. The react version seems to use `
>>> clientWidth
>>> <https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth>` to
>>> determine the rendered width of the component and uses that when
>>> positioning visual elements. As far as I'm aware there is no way to achieve
>>> this with Elm.
>>>
>>> I would really appreciate any pointers on my approach, particularly if I
>>> have misunderstood the `reusable view` approach, and any ideas on how
>>> overcome the fixed width limitation mentioned above.
>>>
>>> Thanks,
>>>
>>> Michael
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Elm Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to elm-discuss+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm `reusable views`

2017-08-03 Thread Peter Damoc
You could try to use MutationObservers to ferry that information in Elm:
https://ellie-app.com/3VFHVxMsW2ya1/0

Unfortunately, I don't know enough about them to provide a solution that
would actually monitors their resizing but maybe someone else could.




On Thu, Aug 3, 2017 at 11:43 AM, enetsee  wrote:

> Hi,
>
> I have been trying to create a `resuable view` following the structure
> outlined in evanczs `elm-sortable-table`
>  and other examples,
> including:
>
>- abadi199s `datetimepicker`
>
>- thebriticans `elm-autocomplete`
>
>
> I was attempting the reproduce the range slider from Palantir's
> BlueprintJS component library (example here
> ). My
> Elm version is here , with a live
> version in Ellie here .
>
> The Elm version extends the original by allowing the user to specify the
> scale that should be used. The live demo shows both a linear and
> logarithmic scale; the latter is particularly useful when asking users to
> select values which have a heavily skewed distribution (common in finance
> and insurance).
>
> The main limitation of the Elm version compared with the original is
> having to specify a fixed width. The react version seems to use `
> clientWidth
> ` to
> determine the rendered width of the component and uses that when
> positioning visual elements. As far as I'm aware there is no way to achieve
> this with Elm.
>
> I would really appreciate any pointers on my approach, particularly if I
> have misunderstood the `reusable view` approach, and any ideas on how
> overcome the fixed width limitation mentioned above.
>
> Thanks,
>
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Can we get a patch release of elm-lang/core?

2017-07-30 Thread Peter Damoc
On Sun, Jul 30, 2017 at 4:13 PM, Filip Haglund 
wrote:

> I'm currently blocked on this bug https://github.com/elm-lang/core/commit/
> 8e885c9bd4a7556ee039e2f53bbb3a1555d0243e#diff-
> de88ec52111a9d7bd82177e4654bb0f0R449 . It's been fixed months ago, but
> there's no patch release available.
>
> Is 6.0.0 very close to being released, or can I get a patch release for
> this bug? :)
>
> As far as I see it, 6.0.0 will be part of 0.19 and that Elm version isn't
even in the alpha release so... it will still take some time.

How are you blocked exactly? I mean, couldn't you just use the
implementation from the commit?



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Best practices for designing models in the Elm Architecture - lean or rich?

2017-07-25 Thread Peter Damoc
Keep derived data in the model if it makes sense to keep derived data in
the model.

If you have an expensive function that runs and computes a derived value
and you would have to call frequently this function in your view, then by
all means, computer the derived value in update and save it in the model.

If you don't run into a performance problem like the above, keep your model
clean and just extract the computation in a function. for example, you
could have something like

bmiText : Model -> Html msg
bmiText {weight, height} =
weight / height ^ 2 |> toString |> text

this way, everywhere you need that textual representation, you can use it.




On Tue, Jul 25, 2017 at 4:23 AM, Ray Toal  wrote:

> This might be an opinion-based question so I can't ask it on
> StackOverflow. :-)
>
> I have a trivial beginnerProgram using the Elm Architecture. It has two
> text fields (HTML input elements), one for weight and one for height. The
> onInput attributes of each generate a message. The update function accepts
> the message and produces the new model.
>
> The question is: Should the model (a) consist of the width and height
> only, or (b) also include the computed BMI (width / height^2)? If the
> former, I compute the BMI in the view function; if the latter, I would
> compute it in the update function.
>
> Does anyone have a lot of experience with Elm applications that would lead
> them to believe that keeping models as small as possible and computing
> derived data in the view function is better than making rich models? I
> don't have enough experience with Elm to know. I sense that for a problem
> as simple as mine it really doesn't matter (and I in fact got it working
> both ways), but as I start scaling up my apps it would be nice to know if
> there is best practice here (or not).
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Systemic problem in Object Oriented languages

2017-07-25 Thread Peter Damoc
On Tue, Jul 25, 2017 at 3:32 AM, Erik Simmler  wrote:

> That said, what if we flip the question around? Given that we have
> facilities for encapsulation (unexposed types), what would we gain by
> adding a new set of concepts around mixing data/logic and syntactic sugar
> in the form of "this"? What would this enable?
>

We could have better polymorphism.  For example, we could have something
like traits.

trait Stringable =
{ toString : this -> String
}

type Msg implements Stringable  =
{ tags = Increment | Decrement
, toString = \this ->
case this of
Increment ->
"Add One"
Decrement ->
"Subtract One"

}

This would allow one to declare something like List Stringable that would
accept all String and objects that can be turned into a string because they
implement the Stringable trait.

We would not have to keep putting toString all over our code but rather
decide at the type declaration level how the string representation of the
type should look.

The same argument can be made for serialization too.

As far as I can see it, the prime target for this would be to implement
web-components like nodes that would be just implementations of some node
interface. Behind the scenes we would still get a single source of truth
but this single source of truth would be generated based on these
implementations. In my view, this would eliminate at least some of the
boilerplate.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Systemic problem in Object Oriented languages

2017-07-25 Thread Peter Damoc
On Mon, Jul 24, 2017 at 8:50 PM, Dave Ford  wrote:

> A lot of my early work was centered around UIs which made heavy use of
>> inheritance and mutation.
>>
> I really don't think this is related to the original question. The
> original question was not about inheritance or mutation or even about OO.
> It was about "this" and "combining data with logic". Which were described
> as a "systemic problem".
>
> No one (yet) has convinced me that they are even remotely a problem. No
> one has provided an example. Or any logic to support the claim.
>

I think the added complexity to the language that you mentioned qualifies
as a problem. ;)


>  The fact that "this" has nothing to do with immutability is unrelated to
> my experience.


Most programming languages that have a "this" construct allow mutation.
This is what you have to take into account when discussing this. The very
idea of OOP is that you have independent objects that communicate through
messages. This means that you send an object a message and it mutates its
state (if need be). This mutation is achieved through the use of this/self
or a similar concept.

You cannot simply ignore this historical reality.

Sure, we can have a fully immutable object system but this is not commonly
encountered. If Kotlin has something like this it is an exception not part
of the rule.

Once we acknowledge the issue of mutability we can move the discussion
forward and analyze the benefits of having data and behavior together in
the context of immutability.

I too would love to see an argument against having the data and logic
together in the context of immutability.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Systemic problem in Object Oriented languages

2017-07-23 Thread Peter Damoc
On Sun, Jul 23, 2017 at 1:39 AM, Dave Ford  wrote:
>
> It's not that OOP is bad, but it encourages mutation
>>
> OOP does not encourage nor discourage mutation. Java, Kotlin, Scala and
> OCAML all *allow* mutation. Kotlin, an OO language that I use a lot,
> actually *discourages* mutation. But regardless, my question was not
> about immutability. It was about combining data and logic.
>

I do not know Kotlin but all other OOP languages I've used allowed passing
an object to a function and potentially having that object be mutated by
that function. Maybe "encourage" is the wrong word here but this is an
affordance that will be used.

In any case, from what I remember from the discussions around object
oriented programming around this list, mutability was the key feature that
was brought forward as a source of problems that Elm avoids. It was linked
to state in objects getting out of sync in certain contexts and to the fact
that functions lose their purity.

Another issue is the one you mentioned about the surface area of the
language.
Implementing OOP features would require permanently and irreversibly making
the type system and the language more complex. The topic of typeclasses
(one of the options) has been raised several times. It has been promised at
one point as a feature that the language will gain in time but years
passed and the topic got shelved.

Outside of these two topics (immutability & complexity of the language) I
don't remember seeing arguments for problems brought on by joining data and
behavior together.

I am interested in the topic of web components (I believe that Elm could
benefit greatly from embracing this standard). I've even went as far as to
implement a web components system in Elm (with the help of a little bit of
Native code) and the only real argument against it that I remember is the
argument of mutability. I even tried to implement a mutability-as-service
component in order to try to see if this is possible. I failed. Still...
the intuition of some of the senior developers of Elm is that this would be
possible and that all the nice guarantees of Elm would fly out the window.

This is the main reason I pointed to immutability.
I think the complexity of the language issue is unavoidable but one can
avoid the problems generated by mutability by having an immutable way of
joining data and behavior (the FauxO system I hinted towards being one of
the ways).

I too would be very interested in seeing any kind of argument against
joining data and behavior outside of these two main ones (immutability and
complexity of the type system).


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] main : Program Never Model Msg -- What does it mean?

2017-07-21 Thread Peter Damoc
The main is a *value* of type `Program Never Model Msg`, it is not a
function.

The 3 types after Program, (Never, Model and Msg) are the arguments of the
type in the same way that String is an argument for List in `List String`

You can read that as "a Program that does not take any flags (Never) has
the type `Model` as it's main data type and `Msg` as the main type of
messages flowing through the app", that's the actual, full type.

You can also thing of the `Program` as a container type for the 3 types
that follow it, the same way List is a container type or Maybe is a
container type.



On Fri, Jul 21, 2017 at 8:39 AM, Eeek  wrote:

> I am beginner in Elm, and going through elm-tutorial.org. I have problem
> in understanding the declaration of main function in
> https://www.elm-tutorial.org/en/02-elm-arch/02-structure.html. It says
>
> main : Program Never Model Msg
>
>  What does it represent? I read under functions tutorial that, arguments
> are separated with ->. If there are no arguments then I would expect only
> one return. This don't belong to any of it. What is this way of declaring
> the function types?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Systemic problem in Object Oriented languages

2017-07-20 Thread Peter Damoc
On Thu, Jul 20, 2017 at 12:49 PM, Christophe de Vienne <
christo...@cdevienne.info> wrote:

>
> Well, it is more an intuition after more than 20 years of coding that an
> elaborated opinion.
>
> But the first thing that comes to my mind is the resulting complexity,
> and often confusion. I find that having a clean separation between data
> & logic makes things a lot cleaner, easier to understand and maintain.
>
> I do realize I would need to elaborate a little more to be convincing on
> this, but so far it is all I got :-)
>
>
Out of curiosity, are you keeping your Model, update and view in separate
modules?


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Systemic problem in Object Oriented languages

2017-07-20 Thread Peter Damoc
On Thu, Jul 20, 2017 at 11:52 AM, Dave Ford <df...@smart-soft.com> wrote:

> On Thu, Jul 20, 2017 at 4:14 AM, Peter Damoc <pda...@gmail.com> wrote:
>
>> "this" is associated with mutation. Elm is an immutable language.
>>
>
> I don't think that's true. I might be wrong, but I'm pretty sure that
> "this" has nothing specifically to do with mutation. I write immutable
> objects all day long in java and kotlin making use of "this" and mixing
> data and logic.
>

I'm not saying that "this" implies mutation only that it is associated with
mutating the current object.

Of course one can write immutable objects using "this" but in OO languages
you can also use it to mutate the state of the object.

-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Systemic problem in Object Oriented languages

2017-07-20 Thread Peter Damoc
"this" is associated with mutation. Elm is an immutable language.

In theory, one could have immutable objects where data and logic are
grouped together.
The best expression I've seen so far is the FauxO system in Gary
Bernhardt's Boundaries talk.

Something like this would constitute a non-trivial expansion of the
language and, as far as I can understand it, there are other priorities.


On Thu, Jul 20, 2017 at 10:55 AM, Dave Ford  wrote:

> There is a line from the docs that I am trying to understand: "Elm
> encourages a strict separation of data and logic, and the ability to say
> this is primarily used to break this separation. This is a systemic
> problem in Object Oriented languages that Elm is purposely avoiding."
>
> What is the systemic problem being reference? Is it the [lack of] "separation
> of data and logic" or "the ability to say this"?
>
> I have been programming in Java (an OO language) for a long time. I can
> name dozens of systemic problems in the language. But the ability to say
> "this" is not one of them. Nor is it the commingling of data and logic.
>
> Please help me to understand what the author is talking about.
>
> Thanks.
>
> Side note: "this" *is* a problem in JavaScript. But not in OO generally.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-19 Thread Peter Damoc
On Wed, Jul 19, 2017 at 9:24 PM, David Andrews  wrote:

> Another downside I can think of is that it can only tell you if two values
> have constructors with the same name.  If the same name is used in multiple
> files, they will appear to be equal.
>

If you use raw toString, then yes... but if you are using a comparison
function like the one above, everything should be fine because it will
throw an error if you are trying to give it two different types (as in
types defined in different modules).


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Peter Damoc
I cannot think of any other drawback right now.

Maybe with more information about the context where this is needed a better
option can be found.

I'm actually curious what is the use case that prompted this request as it
has a very XYproblem feel to it.




On Tue, Jul 18, 2017 at 9:03 PM, Birowsky  wrote:

> Petre, give it to me straight. Is the potential deprecation of toString
> the only drawback to this approach? We need to be pragmatic here :}
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Peter Damoc
In theory you could use the inspection offered by toString:

sameConstructor : a -> a -> Bool
sameConstructor first second =
case ( String.words (toString first), String.words (toString second) )
of
( a :: _, b :: _ ) ->
a == b

_ ->
False


That being said, this might not be a good strategy for the future.
I've heard a rumor that toString might move to Debug and its use be
discouraged in production code.





On Mon, Jul 17, 2017 at 1:33 AM, Birowsky  wrote:

> Given:
>
> type Bla = A Int | B Int
> valA1 = A 1
> valA2 = A 2
>
>
> Is there a way for me to check whether `valA1` has been constructed with
> the constructor of `valA2`?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] licensing?

2017-07-05 Thread Peter Damoc
I'm not a lawyer but every elm package has a license declaration in
elm-packages.json.
It defaults to BSD3 which is a very permissive license.

I guess it could be argued that by stating that in elm-package.json, you
are placing your code under that license.

I do think that this should be treated seriously and maybe have elm-package
throw an error if the repository does not have a LICENSE file or if the
license is not OSS approved.



On Wed, Jul 5, 2017 at 8:31 AM, Raoul Duke  wrote:

> i come across elm libraries that lack any LICENSE.md which means i
> can't use them at all and probably have to burn my eyes out of their
> sockets etc. to be on the safe side or something.
>
> i wish people would always include a (good, valid) license, even if it
> is just whatever the legal mumbo jumbo for "all rights reserved" is.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: State of CSS in Elm

2017-07-04 Thread Peter Damoc
On Mon, Jul 3, 2017 at 6:59 PM, Greg Coladarci  wrote:

> A year later, I've just discovered this thread as I am new to the Elm
> world and was interested in how others solved for the styling side of
> things.
>
> In the spirit of trying to figure out how Elm can help solve long-standing
> shortcomings w/ CSS, I see there being two massive opportunities:
>

One of the best projects that came up in this domain is:
https://github.com/mdgriffith/style-elements

The solution will be something like that: separating layout concerns from
surface concerns.

As a more exotic alternative, I have toyed in January with an approach that
rests on custom elements but I haven't put in enough thought to flesh that
out. It was inspired by this article:
https://www.smashingmagazine.com/2017/01/styled-components-enforcing-best-practices-component-based-systems/




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Local third-party packages

2017-07-04 Thread Peter Damoc
On Mon, Jul 3, 2017 at 4:15 PM, Jens Egholm  wrote:

> Just a thought; shouldn't this be available through native Elm package
> management?
>
>
NO!

This kind of unsafe use of code is and should forever be discouraged.

I have dabbled in Native code and the main lesson from my experiences is
that this is highly dangerous and should be avoided as long as possible.

There are contexts in which using Native is unavoidable but one should be
very careful treading on those paths. If they want to encourage others to
follow them, a warning should be issued about dangers.

The official package is for safe things that every beginner could use.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] elm-package.json hierarchy?

2017-07-03 Thread Peter Damoc
It is advisable to have elm-packages.json` in specialty folders like
`examples` or `tests`
Those folders might require packages that you don't want to add as
dependencies to the main `elm-packages.json`


On Mon, Jul 3, 2017 at 9:12 PM, Raoul Duke  wrote:

> Is there very often a good reason to have more than one
> elm-package.json in a project's tree, outside of elm-stuff/? If not,
> it would perhaps be nice if elm-package warned me that I am trying to
> (accidentally, duh) install packages in a subdir of a project that
> already has a higher/top level elm-package.json, so that I don't then
> have to spend more time cleaning up that accidental mess.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Making useless HTML Attributes impossible

2017-07-01 Thread Peter Damoc
On Sat, Jul 1, 2017 at 9:35 PM,  wrote:

> It's been some time that I'm thinking about type checking HTML Attributes
> to ensure at compile time that useless attributes can't be set on HTML. For
> instance, it makes no sense to set Html.Attributes.src to an h1 title.
>

To my understanding this restriction would have to be expressed in the type
signature.
How would the type signature for the `h1` would look like exactly?


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Newbie program not working correctly

2017-06-23 Thread Peter Damoc
Hi Casper,

Just force an empty value when the age is 0
Like this:
https://ellie-app.com/3yrgPqxp52ha1/0


On Fri, Jun 23, 2017 at 12:08 PM, Casper Bollen  wrote:

> I wrote a small program as a newbie project in Elm: https://ellie-app.com/
> 3ynWqjPcP87a1/0.
>
> In this program I calculate the correct input field according to the value
> in the model:
>
> view : Model -> Html Msg
> view model =
> let
> toInput attrs =
> input attrs []
>
> ageInput =
> let
> attrs =
> if model.age == 0 then
> [ name "age", type_ "number", placeholder "Leeftijd 
> in jaren" ]
> else
> [ name "age", type_ "number", value (toString 
> model.age) ]
>
> _ =
> Debug.log "Attrs" attrs
> in
> attrs
> |> List.append [ onInput Update ]
> |> toInput
> in
> div [ style [ ( "margin", "100px" ) ] ]
> [ div [] [ text "Voer een leeftijd in" ]
> , ageInput
> , button [ onClick Calculate ] [ text "Bereken" ]
> , div [] [ text ("Gewicht: " ++ toString (model.weight) ++ " kg") 
> ]
> ]
>
>
> However, if you count up and then down to zero, the input field is
> rendered correctly showing the placeholder when age = 0. But when you count
> down to negative values, the negative values are shown, although the
> model.age value = 0.
>
> Furthermore, the Debug.log "Attrs" is never shown in the debug view.
>
> What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: The way forward for Elm Arrays

2017-06-12 Thread Peter Damoc
On Mon, Jun 12, 2017 at 8:08 AM, Evan  wrote:

> Syntax
>
> I was formerly somewhat keen on having special syntax for other
> collections. For example, OCaml allows you to say [| 1, 2, 3 |] to create
> an array. Hassan made a really nice proposal
>  to have it be #[ 1, 2,
> 3 ] back in 2015. Since then I realized you can do the following:
>
> a = Array.fromList
> s = Set.fromList
> d = Dict.fromList
>
> array =
>   (a[ 1, 2, 3 ])
>
> set =
>   (s[ 1, 2, 3 ])
>
> dict =
>   (d[ 1 => "Tom", 2 => "Sue", 3 => "Jane" ])
>
> (=>) = (,)
>
> This is 1 or 2 characters off all the proposals out there, and it is
> visually much nicer in my opinion.
>


This might sound silly but wouldn't it be possible to have the same syntax
and let the programmer make the type concrete with usage?

array : Array
array = [1, 2, 3]

list : List
list = [1, 2, 3]

I'm asking because we already have a similar situation with `number` where
one ca declare both Int and Float the same way and the compiler is able to
figure out the actual type.

Maybe something similar can be done for dictionaries/records too:

record : Record
record = { field = "value"}

dict : Dict
dict = { key : "value"}

set : Set
set = {1,2}


The main advantage of a dictionary syntax like above is that it is familiar
for people coming from python/javascript.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] explain how Task works

2017-06-09 Thread Peter Damoc
Process.sleep time is creating a Task that will be running for the duration
of the time and then produce an empty tuple.

Task.andThen is taking this produced task and after it finishes it calls
the provided function (always <| Task.succeed msg)

(always <| Task.succeed msg) is equivalent to (\_ -> Task.succeed msg) and
is a function that ignores its argument and produces a Task that finishes
immediately producing the provided msg.

Task.perform identity  takes the above produced Task and converts it to a
Cmd. identity is defined as identity x = x this means that whatever is the
result of the task will be the result of the Cmd.

That being said, the function looks a little bit silly as the Task.andThen
is redundant. It should have been:

delay : Time -> msg -> Cmd msg
delay time msg =
  Process.sleep time
  |> Task.perform (always msg)


you can see it working here:
https://ellie-app.com/3r6knRYxB2Za1/0



On Sun, Jun 4, 2017 at 3:56 PM,  wrote:

> Can you explain, at a beginner's level, how Task works in the following 2
> lines under Process.sleep ?
>
>
> delay : Time.Time -> msg -> Cmd msg
> delay time msg =
> Process.sleep time
> |> Task.andThen (always <| Task.succeed msg)
> |> Task.perform identity
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] What is the Elm equivalent of a Data Specification Language (EDN in Closure, ADTs, etc)?

2017-06-09 Thread Peter Damoc
Hi Gaurav and welcome to Elm!

Your intuition is correct, you should emphasize understanding the basic
data structures and build something with them.

If you have a concrete problem you are trying to solve you will be focusing
on finding the solution.

Without a concrete problem is tempting to go into your knowledge from other
programming languages and try to understand Elm in terms of design. This
path is less fun than the one where you implement something.

Go through the guide:
https://guide.elm-lang.org/

Play with the examples:
http://elm-lang.org/examples

One thing you could try, for example, is to use the field example and the
http example together so that you can type the topic
http://elm-lang.org/examples/field
http://elm-lang.org/examples/http




On Fri, May 26, 2017 at 3:57 PM, Gaurav Rampal 
wrote:

> Hi,
>
> I am new to Elm, and thank you for your patience with my questions.
>
> Since the emphasis in functional languages is on keeping functions pure it
> seems that an equivalent emphasis must be placed on structuring data.
>
> Formal computer science has ADT, Lisp has S-expressions, Clojure has EDN.
> So what is the equivalent in Elm? Or should I emphasize understanding the
> basic data structures and Union Types.
>
> Thanks
>
> Gaurav
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Add css classes to existing html nodes

2017-06-08 Thread Peter Damoc
Hi Eike and welcome to Elm.

You could add some kind of a class to the div that's holding the markdown
generated html and use that as a selector.

If you need something more complex than that, you might need to use html
inside the markdown

Here is how to do both:
https://ellie-app.com/3r5tc7YsmmCa1/1




On Fri, Jun 9, 2017 at 2:13 AM,  wrote:

> Hallo Elm users,
>
> I'm creating my first app with Elm, and I'm really enjoying it. I'm using
> the markdown package to generate html from user input. I'd like to add css
> classes to certain (i.e. to tables) elements generated by this library. I
> didn't find a way to do this. Is this possible?
>
> Thank you and regards
> Eike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Adding CSS produced by a view function to the document's

2017-06-06 Thread Peter Damoc
It seams that you have driven yourself into a corner because of a series of
choices that you made with your code architecture.

The best way forward is to refactor you code so that you decouple the style
from the view.
You should be able to get both of them from the model independently.

Once you've done that, you will just need to call the style function with
the new model in `update` and push the output through the port.
On the other side of the port you might want to experiment with a check
against a saved value as to not trigger needless parsing of the mounted
CSS.





On Mon, Jun 5, 2017 at 1:46 PM, Francesco Orsenigo <
francesco.orsen...@gmail.com> wrote:

> I am experimenting with view functions that produce both html content and
> the style that should be applied to that markup, as in
>
> myView : Model -> ( Html msg, List CssRule )
>
> So far, I have been rendering the above by creating a 

Re: [elm-discuss] Platform.Cmd.batch executes commands in reverse order

2017-05-12 Thread Peter Damoc
On Fri, May 12, 2017 at 8:07 PM, Frank Bonetti 
wrote:

> > Imagine for a second that the first task takes 2 seconds the second task
> 1 second and the third 500ms. They finish in reverse order. If you want
> their result immediately after they finish, the results will come in the
> wrong order.
>
> Totally understand. Why do the commands *start* in reverse order though?
>

What you are seeing is an artifact of the current implementation.
In short it happens because of the way lists are implemented and because it
takes the first element from a list (car) and cons it to another list
The simplified version of what happens is exemplified by this ellie example:
https://ellie-app.com/39Qy5qycs8Qa1/0

Now, if you want to go further and ask another *why*, you will have to get
very intimate with the rest of the implementation details in order to
understand the trade-offs in various approaches and to understand why this
one has been chosen. (I can only guess that it was a performance reason)

If you have enough JS knowledge you can dig deeper into the Platform/Scheduler
code
.

Elm's JS kernel code is quite readable.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Platform.Cmd.batch executes commands in reverse order

2017-05-12 Thread Peter Damoc
On Fri, May 12, 2017 at 7:33 PM, Frank Bonetti 
wrote:

> Also, to the best of my knowledge, the only way to execute Tasks
> concurrently and independently is to use Cmd.batch.
>

Yes. But you cannot have concurrency and guaranteed ordering in the same
time without some kind of synchronization mechanism.

Imagine for a second that the first task takes 2 seconds the second task 1
second and the third 500ms. They finish in reverse order. If you want their
result immediately after they finish, the results will come in the wrong
order.

Also, regarding not being guarantees for order here is an older issue in
the core where this is mentioned:
https://github.com/elm-lang/core/issues/730#issuecomment-253584490




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Platform.Cmd.batch executes commands in reverse order

2017-05-12 Thread Peter Damoc
Here are two approaches to just adding the texts (I'm assuming some
interface where you want to send a series of messages one after the other
and having the user seeing them arrive one after the other with some delay
between them)

with subscriptions:
https://ellie-app.com/39PpTzWp5y3a1/0

without subscriptions:
https://ellie-app.com/39PpTzWp5y3a1/1



On Fri, May 12, 2017 at 6:36 PM, Frank Bonetti 
wrote:

> If you batch a list of commands, they will be executed in reverse order.
> For example:
>
> Cmd.batch
> [ Task.perform (always (AddString "first")) (Task.succeed ())
> , Task.perform (always (AddString "second")) (Task.succeed ())
> , Task.perform (always (AddString "third")) (Task.succeed ())
> ]
>
> Will print:
>
> third
> second
> first
>
>
> Has anyone else noticed this behavior? If so, do you know why Cmd.batch
> was implemented this way?
>
> Here's a demo:
> https://ellie-app.com/39NxYQfDCHMa1/0
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Platform.Cmd.batch executes commands in reverse order

2017-05-12 Thread Peter Damoc
The execution of a Cmd.batch list of commands has not ordering guarantee.
What you see is an artifact and you should not treat it as a predictable
way of execution.
The way to think about a Cmd.batch is that they will get executed and you
will eventually get a reply.

If you need a list of tasks executed in order, you need to implement what
you mean by that yourself.
For example, Task.sequence executes all tasks in order and if one fails,
the entire execution fails.
Task.andThen is another way to chain execution where you have access to the
result of the previous execution.
It depends on what you want to happen.



On Fri, May 12, 2017 at 6:36 PM, Frank Bonetti 
wrote:

> If you batch a list of commands, they will be executed in reverse order.
> For example:
>
> Cmd.batch
> [ Task.perform (always (AddString "first")) (Task.succeed ())
> , Task.perform (always (AddString "second")) (Task.succeed ())
> , Task.perform (always (AddString "third")) (Task.succeed ())
> ]
>
> Will print:
>
> third
> second
> first
>
>
> Has anyone else noticed this behavior? If so, do you know why Cmd.batch
> was implemented this way?
>
> Here's a demo:
> https://ellie-app.com/39NxYQfDCHMa1/0
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Tour of an open-source 4,000 LoC Elm SPA

2017-05-08 Thread Peter Damoc
another advantage to a build system (webpack) is that you could create a
`docs` folder where to output the current build, mount that folder to be
used by the project as its Github Pages root and link it from the
README.md.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Tour of an open-source 4,000 LoC Elm SPA

2017-05-08 Thread Peter Damoc
First, thank you so much for taking time from your already busy schedule to
solve this for the community!
I think it is an amazingly useful project as it short-circuits a lot of the
potentially time-hungry decisions.

Can you comment on why you did not use the elm-webpack-loader?
I'm trying to understand if we are moving towards a better approach or if
there are other considerations.

The main advantage to using the loader would be to show a way to integrate
Elm with the rest of the web tech especially SCSS and to provide a
development/deployment build environment.




On Mon, May 8, 2017 at 10:59 AM, Richard Feldman <
richard.t.feld...@gmail.com> wrote:

> I get asked if there are any sizeable open-source Elm SPA examples out
> there...so I made one!
>
> Hope it's useful: https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] List of all members of a union type

2017-05-03 Thread Peter Damoc
On Wed, May 3, 2017 at 7:00 PM, Charles Scalfani 
wrote:

> Adding this to the language feels like how other languages evolve, which
> is haphazardly.
>
> I rather see a more general solution to this problem via some type of
> constraint-based type. For example, imagine you can define something as
> *String* but with a constraint that limits the values they can contain.
> This would solve all current problems we have with using types as Enums.
> We'd have exhaustive case statements checking and since it's already a
> String converting to String is unnecessary.
>

A general solution would bring its own set of issues as all general
solutions tend to be abused. As such, a general solution needs way way more
thought and design.

Anyway, I'm not arguing that what I said above is necessarily a good idea.
I haven't given it that much thought.
All I say is that it is one conceivable way.
The main advantage I see is that the language doesn't really change, it's
just a convention that turns some already expressible types into something
that can do a little bit more.




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] List of all members of a union type

2017-05-03 Thread Peter Damoc
On Wed, May 3, 2017 at 6:17 PM, Max Goldstein 
wrote:

> Building on Charles, how would this handle recursive union types?


This can be handled as a convention at compiler level.

A new restricted type variable could be created, let's call it "enumerable"
and only non-recursive, non-function types be "enumerable".
If an non-enumerable type is used, the compiler throws an error the same
way it throws an error if a non-comparable type is used as a Dict key.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] List of all members of a union type

2017-05-02 Thread Peter Damoc
On Wed, May 3, 2017 at 6:56 AM, Joey Eremondi 
wrote:

> The problem is, this would only work when all the constructors had 0
> arguments , or arguments of the same type. Otherwise, what would the type
> of such a list be?
>

But if we would have a function like:

defaultValues : Type a -> List a

where Type a would be some compiler magic value that contains the type info
of a, wouldn't we be able to say

type WeekDay = Mon | Tue | Wed | Thu | Fri | Sat | Sun

allDays = defaultValues WeekDay

defaultValues would return a list of all the default values for all the
constructors. So, if the constructor takes 0 parameters would return the
tag, if it takes 1 value would return the value created by applying the tag
to the default value of the type it contains (eg `Some Int` would return `Some
0`). The default value for a type can be by convention the first tag for
tagged unions. For the number it would be 0 and for String "".




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Moving on

2017-04-27 Thread Peter Damoc
On Thu, Apr 27, 2017 at 1:48 PM, Rehno Lindeque 
wrote:

>
> This grey list would be backed by a clear process of getting things on the
>> list that would include a checklist of mandatory things.
>> This checklist would be like a rule list and breaking any of the rule
>> would have to happen after a serious benefits analysis done under the
>> supervision of that experienced Elm programmers group I mentioned earlier.
>>
>
> If this were the route people decide to take, I get the impression that
> this is the sort of thing elm-community does quite well. Perhaps a
> "greylist" could be simplified to https://github.com/elm-community/*.
>

Of course, that would be the optimal course.
I guess this would make the packages a very light shade of grey, closer to
something semi-official than something apocryphal. :)




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Moving on

2017-04-27 Thread Peter Damoc
On Thu, Apr 27, 2017 at 12:59 PM, Wojciech Piekutowski <
w.piekutow...@gmail.com> wrote:

> Peter, did you mean https://github.com/gdotdesign/elm-github-install for
> installing packages with missing Web APIs?
>

No.  elm-github-install allows for too much freedom.

What I had in mind was more like a grey-list and something similar to
elm-github-install but constrained to this grey-list.
This grey list would be backed by a clear process of getting things on the
list that would include a checklist of mandatory things.
This checklist would be like a rule list and breaking any of the rule would
have to happen after a serious benefits analysis done under the supervision
of that experienced Elm programmers group I mentioned earlier.





-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Scaling Elm

2017-04-26 Thread Peter Damoc
On Wed, Apr 26, 2017 at 7:13 PM, Dwayne Crooks 
wrote:

> How about writing an Elm front-end for https://github.com/
> gothinkster/realworld.
>

This is what I'm actually contemplating right now.
I'll explore it some more next week.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Moving on

2017-04-25 Thread Peter Damoc
On Wed, Apr 26, 2017 at 5:17 AM, John Orford  wrote:

> My 2c on above...
>
> 1) web components - once they're a standard they will be a must.
>
> Perhaps they feel like a necessity now (I am sold) but they're still in a
> flux, browsers support bits and pieces, some things haven't been finalised
> yet.
>

V1 has been accepted and assumed by the major browser providers for some
time and we will probably see official support in the evergreens this
summer but this is beside the point.

The idea of custom elements could have been implemented in Elm without
browser support if this would have been desired.

Unfortunately, this idea comes packaged together with the idea of localized
state and this seams to be rejected on philosophical grounds.
I seriously doubt we'll ever see web-components support without a proper
dialog around this subject.

I've seen the idea of "mutation-as-service" being put forth as the main
drawback of web-components and I would love to see a proof-of-concept for
this just so that I can accept that this is a bad idea. Heck, I even tried
to implement such a proof-of-concept and failed.

Anyway... I used to feel worse about this topic but I realized that there
are still a lot of things that I can do and haven't done yet so... I have
options.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Moving on

2017-04-25 Thread Peter Damoc
On Tue, Apr 25, 2017 at 7:42 PM, Eirik Sletteberg  wrote:

> Since you mention pitch forks...
> Maybe there's a potential for an Elm fork.
>

There are so many unexplored options that don't need any kind of fork of
Elm.
Reaching for something as drastic as a fork of the main language seams like
a gigantic waste of energy. :)



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Unexpected error when parsing what seems to be reasonable code (Bug in parser maybe?)

2017-04-23 Thread Peter Damoc
On Sat, Apr 22, 2017 at 11:50 AM, Dwayne Crooks 
wrote:

> However, if I update the let bindings as follows:
>
> let
>> defaultViewConfig = Rating.defaultViewConfig
>> ratingViewConfig =
>> { defaultViewConfig | readOnly = model.readOnly }
>> in
>> ...
>
>
> Then, there is no error. Am I missing something or is this a bug in the
> parser?
>
> This is related to an active topic around record update syntax.
In short, currently it is not allowed to directly update nested records. ({
Rating.defaultViewConfig | readOnly = model.readOnly } is invalid syntax)
The temporary solution is the one you stumbled upon: creating an alias for
the nested record.

Another solution would be to use custom functions:


updateReadOnly : { a | readOnly : Bool } -> Bool -> a
updateReadOnly rec readOnly =
{ rec | readOnly = readOnly }

and then use it like:

ratingViewConfig =
updateReadOnly Rating.defaultViewConfig True


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Optimisation in Elm

2017-04-23 Thread Peter Damoc
Hi Ana,

1. Elm is fast because it use a very fast implementation of a virtual dom.
2. Elm compiler outputs JavaScript so all the low level memory concerns are
handled by the JavaScript VM, not by Elm
3. No, Cmds do not influence the purity of Elm. If a function returns Cmds,
it will always return the same Cmds. Executing those Cmds might lead to
different results BUT that's a different concern.


On Fri, Apr 21, 2017 at 3:10 PM, Ana Borovac 
wrote:

> Hi,
>
> I have some theoretical questions:
>
> - why is Elm so fast? is there some kind of tail-recursion behind or is
> this just the part that JavaScript does?
>


> - how is the storage mastered (garbage collection)?
> - does commands (Cmd) influence on pureness of Elm?
>
> Thank you so much for your help!
>
> Ana
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Looking for a better way to use `andThen` chains (and other beginner questions)

2017-04-23 Thread Peter Damoc
On Sat, Apr 22, 2017 at 12:37 AM, Stefan Matthias Aust 
wrote:

>
> *My first question*: Is there any way to create a constrained type like
> "something that has a `no` field?
>
>
Right now, I have a lot of nearly identical code like this:
>
> findStar : StarNo -> Game -> Maybe Star
> findStar no game =
> List.head (List.filter (\star -> star.no == no) game.stars)
>
> findPlanet : PlanetNo -> Star -> Maybe Planet
> findPlanet no star =
> List.head (List.filter (\planet -> planet.no == no) star.planets)
>

You could use record pattern matching to create generic functions but in
the above case that won't work because the container name is different.

Here is how it would have looked if the container name would have been the
same (in this case `children`)

findChild : Int -> { b | no : Int, children : List { a | no : Int } } ->
Maybe { a | no : Int }
findChild no parent =
List.head (List.filter (\child -> child.no == no) parent.children)

I used Int for the `no` but you you can leave that also as a parameter
(e.g. `c`)


> *Second question*: Is there an easy way to replace an element in a list?
>
> You can create a generic helper like

swapIfSameNo : { a | no : Int } -> { a | no : Int } -> { a | no : Int }
swapIfSameNo a b =
if a.no == b.no then
a
else
b

and then the updates would be simpler

updatePlanetInStar : Star -> Planet -> Star
updatePlanetInStar star planet =
{ star | planets = List.map (swapIfSameNo planet) star.planets }


The same comments from above apply. If you have a generic name for the
container (children) you can make this a generic updateChild function that
would work on both.


> Sidenote: I'd love to use
>
> { game | stars[x].planets[y] = planet }
>
> and let the compiler deal with all that stupid boilerplate code. I realize
> that for this to work, I'd have to use `Array` (a rather unsupported type)
> instead of `List` but that would be fine. That way, I could alias my `no`
> to indices. By the way, do I really had to create my own `nth` function for
> Lists?
>

What make you think Array is unsupported?

Regarding indexes in arrays (or lists for that matter), it would be lovely
to be able to say things like that but it is unsafe. You might be using an
out of bounds index.
There are no solutions in contexts like these, only tradeoffs. Elm choses
to make things more verbose and more explicit in order to guarantee safety.
That's the tradeoff that Elm chose.



> *Third question*. When implementing `BuildDefense`, I need to convert the
> no's to records and this could fail. Instead of working with `Maybe`, I use
> a `Result Error a` type and `Error` is a sum type that contains all the
> errors that could occur. However, I get some really ugly chaining…
>
> buildDefense : TeamNo -> StarNo -> PlanetNo -> Int -> Game -> Result Error
> Game
> buildDefense teamNo starNo planetNo amount game =
> findTeamR teamNo game
> |> Result.andThen
> (\team ->
> findStarR starNo game
> |> Result.andThen
> (\star ->
> findPlanetR planetNo star
> |> Result.andThen
> (\planet ->
> if amount < 1 then
> Err InvalidAmount
> else if planet.owner /= team.no
> then
> Err NotYourPlanet
> else if planet.resources < amount
> * defenseCost then
> Err NotEnoughResources
> else
> planet
> |> addDefense amount
> |> subtractResources
> (amount * defenseCost)
> |> updatePlanet star
> |> updateStar game
> |> Ok
> )
> )
> )
>
> How am I supposed to write this "the Elm way"?
>

What I would try to do different is split buildDefense in two between
finding the proper planet and doing something with it

findPlanet : TeamNo -> StarNo -> PlanetNo -> Game -> Result Error ( Planet,
Star )
findPlanet teamNo starNo planetNo game =
findTeamR teamNo game
|> Result.andThen
(\team ->
findStarR starNo game
|> Result.andThen
(\star ->
findPlanetR planetNo star
|> Result.andThen
(\planet ->
if planet.owner /= team.no then
 

Re: [elm-discuss] Re: Comments on the TEA Components package

2017-04-19 Thread Peter Damoc
On Wed, Apr 19, 2017 at 11:19 PM, Yosuke Torii  wrote:

> I'm curious what makes it sound that way, since as you noted, that is not
>> the point I'm making.
>>
>
> I don't know if others feels like me or not. But at least for me, "no
> components" sounds a bit confusing (it is in official guide too).
>

I view it as destructive so, you're not alone in seeing something not OK
with that.


> Also, "no components, no nesting TEA" does not answer the problem
> discussed here. So how can we do instead? Maybe introducing sortable-table
> pattern is more constructive for this discussion. I think it is a variant
> of TEA, managing its own state, but still keeping the form of "reusable
> *view*". So great!
>

the sortable table is a clever component that pushed the external call to
update inside the view.
You still need what used to be the ChildMsg tag but now instead of calling
the Child.update and saving the state it receives the updated state and
just saves it.

Other than the update trick, it's more or less the same thing as the old
MUV triplets.
You can even use the pattern to do nesting.

The problem is that this approach makes it impossible (as far as I could
see) to implement the components that need side effects (like the old
RandomGif list)






-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Scaling Elm

2017-04-19 Thread Peter Damoc
Hello community,

Scaling Elm apps seams to be a recurring topic.

I was wondering if maybe we could negotiate a minimal set of functionality,
something similar to ToDoMVC, that could be implemented using different
approaches to explore what could be the best way to structure the code.

What should this minimal example cover and what this minimal example should
be (topic)?

I'll start the list with some bits of functionality that I would like:

- multiple pages with common structure (sidebar/navbar)
- navigation without reloading the app (SPA routing without the hash)
- authentication
- complex widget reuse (a module/widget that generates side-effects; e.g. a
weather widget, some stock ticker, an ad provided by a third party)
- styling (CSS)

I would also like the example to cover real world concerns of:
- using a build manager to integrate with other technologies
- development mode - deployment build
- testing

As for topic, I was thinking about an interface to the MusicBrainz Database
(a simplified interface).

What do you think?
What bits of functionality would you like to see exemplified?
Are you aware of any other project (in other languages) that exemplifies a
minimal set of functionality and could be used as a template?


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Comments on the TEA Components package

2017-04-19 Thread Peter Damoc
so, the Model-View-Update triplet *is NOT* the wrong unit of composition
for Elm applications? :)

Don't you see how people starting up with Elm could get confused by this
kind of messages?

On Wed, Apr 19, 2017 at 10:03 AM, Richard Feldman <
richard.t.feld...@gmail.com> wrote:

> > How do you propose to split the functionality one has in a highly
> complex app with a lot of pages without using those triplets?
>
> I don't haha...I just defended their use a few posts ago, complete with
> the specific example of the reusable signup form.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Comments on the TEA Components package

2017-04-19 Thread Peter Damoc
On Wed, Apr 19, 2017 at 9:19 AM, Richard Feldman <
richard.t.feld...@gmail.com> wrote:

> My point that there's a simple way to scale Elm applications by
> abstracting at the function level has gone uncontested for awhile in this
> thread. I think at this point I've said my piece and might as well move on.
>
> It's cool for people to have philosophical goals separate from the goal of
> a nice scaling experience, but I honestly don't think I have much to
> contribute to those discussions. :)
>
I am genuinely interested in a reasonable answer to the encapsulation of
side-effects components/widgets.
I have tried to think about this when I tried to reimplement the old
tutorial and failed to find a proper solution.
I remember asking about it here (or maybe on Slack) and have no memory of
an answer.

I don't know how to encapsulate the kind of functionality that was
demonstrated in the RandomGif or the SVG Animation with the currently
recommended approach.

It's fine to say, "we don't do it like we used to do it" but there was no
functionally equivalent solution offered.

Also, one could use the old approach to scale by splitting an app into
pages.
I have no idea how to avoid Model-Update-View when implementing the idea of
Pages.

You say:
>
> *we learned that a Model-View-Update triplet is the wrong unit of
> composition for Elm applications.*


How do you propose to split the functionality one has in a highly complex
app with a lot of pages without using those triplets?


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Comments on the TEA Components package

2017-04-18 Thread Peter Damoc
On Wed, Apr 19, 2017 at 2:58 AM, Richard Feldman <
richard.t.feld...@gmail.com> wrote:
>
> "Everything ought to have the same API" is a much harder claim to defend.
> It sounds wrong at face value, and I haven't seen any evidence (in this
> thread or elsewhere) to convince me that it's a wise goal to pursue. :)
>

But isn't the entirety of the html package and actual example of an unified
API?
All the widgets there have the same API: widget : List (Attribute msg) ->
List (Html msg) -> Html msg


checkbox : (Bool -> msg) -> Bool -> Html msg



How about the case where one has calls to a server involved? for example a
weather widget or some kind of "Quote of the day" widget, a stocks ticker,
etc.
How does one handles side-effects (http, random, time etc) with this
pattern?






-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Is there a way to get a compile-time error when a field is added to a record type but its corresponding JSON encoder is not?

2017-04-07 Thread Peter Damoc
To my understanding, the only way to add that kind of safety is to
implement a build plugin that analyzes your encoders.

The encoder code is perfectly valid because you might not want to encode
everything from a record so, Elm will allow you to do that just like it
will allow you to name those JSON field whatever you like (even misspelled
names of your record fields)




On Fri, Apr 7, 2017 at 8:37 AM, Andres Riofrio  wrote:

> For example, I have the following code:
>
> type alias Account =
>   { id : Int
>   , name : String }
>
> -- ... in another module ...
>
> accountToJson : Account -> Json.Encode.Value
> accountToJson act = Json.Encode.object
>   [ ("id", Json.Encode.int act.id)
>   , ("name", Json.Encode.string act.name)
>   ]
>
> If I add a field to Account, I'd like the compiler to make sure it won't
> be skipped in the output JSON. The way I have written the encoder, the
> compiler will happily let me skip the field in the serialized version of my
> data.
>
> I thought about using destructuring like so:
>
> accountToJson : Account -> Json.Encode.Value
> accountToJson {id, name} = Json.Encode.object
>   [ ("id", Json.Encode.int id)
>   , ("name", Json.Encode.string name)
>   ]
>
>
>
> But according to the documentation
> , this will compile
> fine even if Account gains a new record.
>
> Any ideas on how to add this bit of type-safety to my application?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: elmvm (Elm Version Manager)

2017-04-06 Thread Peter Damoc
On Thu, Apr 6, 2017 at 3:43 PM, Eirik Sletteberg 
wrote:

> None of these tools are mentioned in the Elm documentation. It only points
> to installers and the npm module.


Exactly my point.
There needs to be a better advertising of the ecosystem both in terms of
tools and in terms of packages.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: elmvm (Elm Version Manager)

2017-04-06 Thread Peter Damoc
On Thu, Apr 6, 2017 at 2:00 PM, Richard Wood  wrote:

> Very healthy having competing options in the ecosystem
> :)
>
> No, this is against Elm philosophy as I understand it.
Elm aims to have one, excellent option rather than a plethora of slightly
different libraries/tools.

The fact that there are so many tools for this simple task is actually
indicative of problems in the ecosystem.
It seams that people interested in a certain functionality don't find it
even if it exists.





-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Bug report (Undefined is not a function!)

2017-03-29 Thread Peter Damoc
If you want a SSCCE, here it is:
https://ellie-app.com/M5sydznVwXa1/0

This is what you might be doing (the equivalent, of course).

On Wed, Mar 29, 2017 at 9:32 AM, Mark Hamburg  wrote:

> I've now seen something like this a few times. The last time I tried to
> build an SSCCE, the bug went away when I looked more closely so I expect to
> get nasty messages from the bug submission system if I try to report it as
> is, but I figured I would see whether anyone else has seen anything like
> this in an effort to narrow in.
>
> This Elm code
>
> operationHandlers : List (Operation.Op Msg -> Maybe Updater)
> operationHandlers =
> [ handleAccountOperation
> ]
>
> handleAccountOperation : Operation.Op Msg -> Maybe Updater
> handleAccountOperation op =
> case Debug.log "handleAccountOperation" op of
> Operation.Account accountID accountOp ->
> applyAccountOperation accountOp
> |> Maybe.map (updateAccount accountID)
> _ ->
> Nothing
>
>
> produces this JavaScript
>
> var _adobe$adlproj$App_SessionData$operationHandlers = {
> ctor: '::',
> _0: *_adobe$adlproj$App_SessionData$handleAccountOperation*,
> _1: {ctor: '[]'}
> };
> var _adobe$adlproj$App_SessionData$handleAccountOperation = function (op)
> {
> var _p5 = A2(_elm_lang$core$Debug$log, 'handleAccountOperation', op);
> if (_p5.ctor === 'Account') {
> return A2(
> _elm_lang$core$Maybe$map,
> _adobe$adlproj$App_SessionData$updateAccount(_p5._0),
> _adobe$adlproj$App_SessionData$applyAccountOperation(_p5._1));
> } else {
> return _elm_lang$core$Maybe$Nothing;
> }
> };
>
>
> Note the problem in bold: At the point where we construct the list, we
> have not initialized the variable being stored in the list. When we then
> try to call the function at the head of the list, we get informed that it
> isn't a function. Boom.
>
> Reversing order does not fix this (and should not be required to fix this).
>
> Mark
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Cmd.map

2017-03-28 Thread Peter Damoc
If you have a series of pages that each has Cmds and you have these pages
unified under one app, you need to lift each page Cmd to become an app Cmd.

There used to be a nesting architecture where this was demonstrated but now
that's been dropped in favor of the Config approach.



On Wed, Mar 29, 2017 at 1:09 AM, Brian Marick  wrote:

> I’m having trouble thinking of a scenario in which you’d use `Cmd.map`.
>
> Is it for a case where you create a `Cmd a` where `a` is something
> different than the usual `Msg`, then transform it into a `Msg`? (When would
> you do such a thing?)
>
> Or for a case where you want to change the `Msg` constructor that `Cmd`
> “wraps”? (Ditto.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm webcomponents for microservice front-end

2017-03-28 Thread Peter Damoc
My suggestion is to create a playground to explore this approach and
proceed with the actual implementation only after you get the details
right.

There are so many ways that this can break that have nothing to do with
Elm.




On Tue, Mar 28, 2017 at 11:19 AM, Charles-Edouard Cady <
charlesedouardc...@gmail.com> wrote:

> Hi Peter! Thanks for your reply!
>
> Front-end composition from microservices is an emerging pattern which
> allows cross-functional teams to independently deploy features (including
> back-end and front-end).
> Each team has full responsibility of the feature they release (from
> back-end to front-end), which gives them full autonomy to release whenever
> they are ready.
> It's a pattern used by Netflix, Amazon or Spotify, to name a few.
>
> You can learn more about it here:
>
> https://technologyconversations.com/2015/08/09/including-front-
> end-web-components-into-microservices/
> http://techblog.scout24.com/2016/01/unexpected-solution-
> microservices-ui-composition/
> https://medium.com/@clifcunn/nodeconf-eu-29dd3ed500ec
>
>
>
> On Tuesday, March 28, 2017 at 8:58:22 AM UTC+2, Peter Damoc wrote:
>>
>>
>> On Tue, Mar 28, 2017 at 9:26 AM, Charles-Edouard Cady <
>> charlesed...@gmail.com> wrote:
>>
>>> I'm composing a single-page application from several microservices
>>> back-ends. Each back-end should render a part of the page.
>>>
>>> Right now I'm considering using webcomponents:
>>>
>>> - main page is in Elm and subscribes to a websocket giving it the list
>>> of microservices it can get webcomponents from
>>> - each microservice serves an html page containing the web component &
>>> its name
>>> - the main page dynamically includes the webcomponent & uses its name to
>>> create the node in the DOM
>>>
>>> This means that whenever I switch a microservice on the component
>>> appears on the page & it disappears when I switch the microservice off.
>>>
>>> The reason I'm using webcomponents here is that I may include
>>> microservices written by third parties who do not necessarily want to be
>>> locked in using Elm, or any specific technology for that matter.
>>>
>>> I therefore need two things :
>>>
>>> (1) the ability to use webcomponents in Elm (I think this has already
>>> been covered, except maybe some conflicts between Elm's virtual DOM & the
>>> webcomponent's virtual DOM)
>>> (2) the ability to write webcomponents in Elm.
>>>
>>> I'm not too sure about number 2: what I've seen in the list so far is
>>> mainly interest in using webcomponents but not so much in writing them.
>>> Does anybody have more information on this? Any help would be greatly
>>> appreciated!
>>>
>>> Here is how you would implement a web component in regular Elm & Polymer
>> https://github.com/kevinlebrun/elm-polymer/tree/master/
>> counter-elm-inside-polymer
>>
>> You will probably need to use some kind of head manipulation for
>> dynamically importing the web-components into your page.
>> I have never tried to do this but my intuition tells me it might be a
>> very bad idea.
>> Have you seen this approach done outside of Elm?
>>
>>
>>
>> --
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Elm webcomponents for microservice front-end

2017-03-28 Thread Peter Damoc
On Tue, Mar 28, 2017 at 9:26 AM, Charles-Edouard Cady <
charlesedouardc...@gmail.com> wrote:

> I'm composing a single-page application from several microservices
> back-ends. Each back-end should render a part of the page.
>
> Right now I'm considering using webcomponents:
>
> - main page is in Elm and subscribes to a websocket giving it the list of
> microservices it can get webcomponents from
> - each microservice serves an html page containing the web component & its
> name
> - the main page dynamically includes the webcomponent & uses its name to
> create the node in the DOM
>
> This means that whenever I switch a microservice on the component appears
> on the page & it disappears when I switch the microservice off.
>
> The reason I'm using webcomponents here is that I may include
> microservices written by third parties who do not necessarily want to be
> locked in using Elm, or any specific technology for that matter.
>
> I therefore need two things :
>
> (1) the ability to use webcomponents in Elm (I think this has already been
> covered, except maybe some conflicts between Elm's virtual DOM & the
> webcomponent's virtual DOM)
> (2) the ability to write webcomponents in Elm.
>
> I'm not too sure about number 2: what I've seen in the list so far is
> mainly interest in using webcomponents but not so much in writing them.
> Does anybody have more information on this? Any help would be greatly
> appreciated!
>
> Here is how you would implement a web component in regular Elm & Polymer
https://github.com/kevinlebrun/elm-polymer/tree/master/counter-elm-inside-polymer

You will probably need to use some kind of head manipulation for
dynamically importing the web-components into your page.
I have never tried to do this but my intuition tells me it might be a very
bad idea.
Have you seen this approach done outside of Elm?



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Web components vs. Native

2017-03-23 Thread Peter Damoc
On Thu, Mar 23, 2017 at 9:33 AM, Maxwell Gurewitz 
wrote:

>
> > You will be able to use a web component ONLY in the view will be as pure
> as it is right now.
>
> Unless I'm misunderstanding you, I'm pretty sure this isn't true.
>

Wonderful! Maybe you can help me with an exploration.
I'm aiming to create a proof of concept where a web-component could be used
in such a way that it behaves like a "mutation as service". (I'm hoping to
not be able to do it)
Please contact me on Slack if you are interested.



> Any violation of purity that is available to native code is also available
> to web components, given that web components can execute arbitrary js when
> they render.  That's why we have silly non-presentational web components
> like polymer's ajax component https://github.com/polymerelements/iron-ajax.
>
>
>
As per the above, I would love to see a proof of concept that shows this.
In JS you have an imperative way of programming and you can do certain
things that are just impossible in the Elm world.


> > Again, I don't think that the use of web components is encouraged.
>
> Why do you feel that way?  My impression is that writing native code is
> discouraged (thus the lack of documentation, and Evan's elm-dev posts on
> native code etc.) while the use of web components is encouraged (thus
> Richard's section on web components in Elm in Action).
>

I have spoken with Richard and this is a very sensible topic as there are
potential nasty consequences that might not be obvious from the start.
Web components do have their role to play and I'm assuming that Richard
might touch on his book on this BUT the topic has not been fully fleshed
out.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Web components vs. Native

2017-03-22 Thread Peter Damoc
To my understanding there is no promotion of the web components as a
standard way of interacting with JS.
They are mentioned as a way of encapsulating complex JS that might fail.
In other words, one could use some complex widget (like google-maps) and
get some functionality into their elm app *fully aware* of the risks
involved.

1. Type safety:

There is none with web components BUT, you do get a nice border control and
black-box encapsulation from the perspective of Elm.
It very similar to using ports only that from my perspective, the
interaction is nicer.

2) Purity guarantees

You will be able to use a web component ONLY in the view will be as pure as
it is right now.
You will not be able to interrogate the web component, you will have to
subscribe to its events just like you subscribe to onClick on a button.
This is very different from Native that you can use all over the place.

3) Versioning guarantees

web components are not part of the Elm ecosystem and so, they are not and
will never be covered by elm-package. Maybe after we get the ability to
describe web-components in pure Elm, you will be able to find
web-components in elm-package.

So if the main motivation for discouraging the use of native is to promote
> safety, why encourage the use of web components?


Again, I don't think that the use of web components is encouraged.
They are only an escape hatch that is available to Elm programmers.

These being said, I do believe that the mechanism of web-components has a
lot to offer to Elm.

I have played with some prototypes and the experience of writing
web-components in Elm is quite lovely.
In an ideal world, we don't use  in Elm but rather 
becomes an Elm implemented web-component.
The web-component standard could be the official way to embed and interact
with Elm apps.






On Thu, Mar 23, 2017 at 1:57 AM, Maxwell Gurewitz 
wrote:

> Hi all.  I'm creating this thread to discuss the relative merits of web
> components and native code.
>
> It's my perception that web components are being promoted within the elm
> community as a standard means of javascript interop, while writing native
> code is discouraged.  In particular, Richard Feldman has recently added a
> section on web components to his book Elm in Action (great book btw, you
> should totally buy it!), and I'd love to get his feedback.
>
> I don't understand this preference for web components over native code.
> As far as I can tell web components and native code lack all of the same
> safety guarantees.
>
> 1) Type safety:
>
> Both native code, and js inside of custom web components have the
> potential to raise exceptions, or produce invalid results due to a lack of
> type safety.
>
> 2) Non-determinacy:
>
> Both native code and js inside of custom web components have the potential
> to introduce non-determinacy.  You can imagine that the google maps web
> component might receive a 500 status response from google during an outage,
> or the author of the component might simply include a Math.random.  This
> will violate the guarantees made by the elm-debugger which disables port
> code from running for exactly this reason, which could prevent you from
> being able to reliable replay UI interactions.
>
> 3) Versioning guarantees:
>
> Neither native code nor web components can be published in elm-package,
> and they both include javascript, so neither can benefit from elm's semver
> enforcement.
>
> Now I understand that web components may be more ergonomic than equivalent
> native code in certain situations e.g. in the google maps case, but they
> don't seem any more or less safe than native code.  Furthermore, they
> impose the cost of an additional build system (bower) and polyfills.
>
> So if the main motivation for discouraging the use of native is to promote
> safety, why encourage the use of web components?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Publishing Elm package that depends on web components

2017-03-15 Thread Peter Damoc
I don't see why not.
Just make sure you document properly the running environment.

To give you an idea, you situation is similar to `elm-mdl` that depends on
the material design CSS being loaded in order to look properly.

On Wed, Mar 15, 2017 at 5:34 PM, 'Jonas Schürmann' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> Hey folks,
>
> is it okay to publish a pure Elm package (no native code, no ports) that
> depends on a custom element (web component) being defined by some other
> Javascript library?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Uncaught TypeError with a value obtained from a decoder

2017-03-14 Thread Peter Damoc
Looks like you hit on this issue:
https://github.com/elm-lang/core/issues/444

Have you tried switching to a different implementation?
http://package.elm-lang.org/packages/Skinney/elm-array-exploration/2.0.2



On Tue, Mar 14, 2017 at 12:35 PM, Matthieu Pizenberg <
matthieu.pizenb...@gmail.com> wrote:

> Thanks Peter,
> After a long process of reducing the code, it came down to (in REPL):
>
> > Array.append (Array.repeat 993 False) (Array.repeat 1 True)
> TypeError: Cannot read property 'length' of undefined
>
> Whereas with 992 instead of 993, it works fine. Should I report this as an
> issue?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Uncaught TypeError with a value obtained from a decoder

2017-03-14 Thread Peter Damoc
Can you produce a SSCCE  with this error?

Are you using any 3rd-party Native code?




On Tue, Mar 14, 2017 at 9:13 AM, Matthieu Pizenberg <
matthieu.pizenb...@gmail.com> wrote:

> Hi, this morning I got into a weird bug with a value obtained from a
> decoder. I got elm code compiling but runtime error.
> I have this inside an update:
>
> let
> groundtruth : Maybe RLE
> groundtruth =
> Decode.decodeString RLE.decode rleString
> |> Result.toMaybe
>
> -- The problem appears when I add this code:
> groundtruthMatrix : Maybe (Matrix Bool)
> groundtruthMatrix =
> groundtruth
> |> Maybe.map RLE.toMatrix
> in
> ( { model | groundtruth = groundtruth }
> , Cmd.none
> )
>
> where the signature of RLE.toMatrix is:
>
> -- Convert a RLE image to a Matrix.
> toMatrix : RLE -> Matrix Bool
>
> and this fonction is working (according to manual tests in REPL).
>
> The error I get when adding the groundthruthMatrix definition is in
> chromium:
>
> main.js:790 Uncaught TypeError: Cannot read property 'length' of undefined
> at calcToRemove (main.js:790)
> at Function.append [as func] (main.js:683)
> at A2 (main.js:92)
> at main.js:16660
> at main.js:7
> at Function.func (main.js:8581)
> at A2 (main.js:92)
> at indexedMap_ (main.js:498)
> at indexedMap_ (main.js:499)
> at Function.indexedMap [as func] (main.js:480)
>
> calcToRemove @ main.js:790
> append @ main.js:683
> A2 @ main.js:92
> (anonymous) @ main.js:16660
> (anonymous) @ main.js:7
> (anonymous) @ main.js:8581
> A2 @ main.js:92
> indexedMap_ @ main.js:498
> indexedMap_ @ main.js:499
> indexedMap @ main.js:480
> A2 @ main.js:92
> (anonymous) @ main.js:8577
> (anonymous) @ main.js:7
> A3 @ main.js:99
> _mpizenberg$elm_image_annotation$RLE$toMatrix @ main.js:16656
> (anonymous) @ main.js:16776
> (anonymous) @ main.js:1887
> A2 @ main.js:92
> (anonymous) @ main.js:16772
> A2 @ main.js:92
> (anonymous) @ main.js:3439
> step @ main.js:4074
> work @ main.js:4132
>
> Do you think there is a way to correct this issue?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Unsafe mechanism

2017-03-13 Thread Peter Damoc
On Mon, Mar 13, 2017 at 11:06 AM, Oliver Searle-Barnes 
wrote:

> What do you think, does this offer a practical route to a greater number
> of pure Elm integration libraries?
>

I seriously doubt it.

The practical route is actually joining forces. It is using multiple pairs
of eyes and multiple brains to solve the Native problem as a community.

Some JS libraries are well designed and their code could be used reasonably
safe within an Elm environment.
You'll still have to assimilate them, that is to adapt their API usage to
the Elm way of managing effects.
This would require a reasonable amount of thought but it can be done and
should be way easier than just reimplementing the functionality in pure
Elm.

In some case, a full reimplementation with Elm paradigms using only bits of
JS code from some source inspiration library might be in order.

In some other cases, the quality of the library is so damn poor and the
assimilation effort is so large that it might make more sense to just write
it from scratch.

The way forward, as I see it, is the generation of a proper documentation
for Native. Not only in the sense of "this is how you do it" but in the
sense of a solid checklist that would make sure you are doing the best that
you can to provide as much reliability as it's possible given the context.

What we have now is the  *AbstinenceONLY™* gospel.
We need proper sex-ed. :)

Just to be explicit, I'm not expecting this from Elm's core team. This
should be a product of the community.
In the absence of this semi-official approach, people will hit unmet needs
like the above mentioned firebase integration and the will try to fulfill
them using Native, potentially breaking a lot of the good practices for
Native code.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: elm + reactive programming

2017-03-10 Thread Peter Damoc
On Fri, Mar 10, 2017 at 7:51 PM, Mark Hamburg  wrote:

> What it feels like one wants to write but can't is the function:
>
> throttle : Float -> Sub msg -> Sub msg
>

I think you might be able to do this kind of thing in an Effects Manager.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Get a simple string from file or htto

2017-03-10 Thread Peter Damoc
If you have web server serving you the html file, you can use something
like  `Http.getString "/a.txt"` to request the contents of that file.




On Fri, Mar 10, 2017 at 4:16 PM, Márton Szabó  wrote:

> Hi,
>
> I am quite new to elm, and I have a noob question. I need the contents of
> a file as a string.
> How can I do that?
>
> For example:
>
> a.txt is in the same directory as my compiled html file.
>
> I need the value of the string in the file simple in a variable in the elm
> program.
>
> How can I achieve that?
>
> Thank you very much!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] 1st newbie question - how to decompose the unwieldy Msg and Update

2017-03-09 Thread Peter Damoc
Alex,

There used to be a documented way of decomposing apps into components by
nesting the model, update and view of the components into the main model,
update and view.

This lead to a lot of debates about inter-components communication and
communication between children and parents.

The approach ended up being abandoned and there is actually a line in de
guide discouraging people from going that route.

Personally, I believe that the warning from the guide is valid with one
exception: pages.

If you have a complex enough app, you should break it into pages and use
the nesting architecture to put the pages together BUT avoid using the
nesting architecture inside the pages, favoring an approach more similar to
the one you can see in sortable table
.

I have tried adapting some of the old nesting examples to this new
architecture (at least the way I understood it). You can take a look at
example 4
https://github.com/pdamoc/elm-new-achitecture/tree/master/examples/4

You can also take a look at elm-taco, a more complex and full featured
example of decomposition.
https://github.com/ohanhi/elm-taco

I'll end by saying that the main problem I see is not the fact that there
is no approach but that there is a lot of freedom afforded by the language
and you can split your code in so many ways.

To my knowledge, there is no official, default way of structuring large
scale, mainly Elm apps.



On Wed, Mar 8, 2017 at 5:17 AM, Alex Rice  wrote:

> Hi all, I am new to Elm, and functional programming, and have been reading
> through all the docs and tutorials. One question that keeps cropping up for
> me is:
>
> How do you break up the Msg union type and the update function into
> logical, manageable and editable pieces in a large Elm project?
>
> type Msg =
>   many | things
>
> and
>
> update : Msg -> Model -> ( Model, Cmd Msg ) =
>   case msg of all... those.. things
>
> So the pattern is, the Msg is a union type of many things, and the update
> function is similarly lengthy case statement.
>
> How does that scale in real web apps? What if you have 100 messages, then
> the update function is always 100 cases long? In the the scenario where you
> are using Navigation.program, then shouldn't the update function only be
> testing the cases which are in scope for the current route of the SPA, not
> all 100 cases? In the Navigation.program examples I have seen, all the
> cases are evaluated.
>
> I hope there is a way to decompose the messages and the update function
> perhaps using some kind of pattern matching, or by some FP techniques, I
> just have not seen it yet. Looking forward to hearing what you think!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Multiple views sharing the same state?

2017-03-03 Thread Peter Damoc
On Fri, Mar 3, 2017 at 10:40 PM, Eirik Sletteberg  wrote:

> Yes, flags works on startup, but it won't work so well after incremental
> updates, will it?
>
> I guess ports is an option (unless you use union types, which makes that
> hard, see the other thread) but I'm a bit concerned about the performance
> overhead of that. With N components the state has to first be serialized to
> JSON once, and then deserialized from JSON to Elm data structure N times.
> Preferably one wouldn't have to go into JS land and back for this to work?
>

Give it a try. It is useless to talk about performance overhead in the
absence of actual code.
Same goes for code structuring and components.
Maybe you'll discover that instead of implementing N components that need
to communicate through ports it's easier to implement one with the
functionality of all three and never leave the safety of Elm for state
management.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Sending tagged unions through ports

2017-03-03 Thread Peter Damoc
On Fri, Mar 3, 2017 at 6:18 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Friday, March 3, 2017 at 3:29:34 PM UTC, Peter Damoc wrote:
>>
>> It makes sense to focus on other issues that are more important BUT,
>> people are having enough troubles with boilerplate introduced by decoders
>> that this could easily be considered a priority.
>>
>
> +1 from me, just for the convenience of being able to do it.
>
> What would the default mapping for a union type to json looks like?
>
> A union type would be specific to Elm so, it would matter less the actual
format as long as it is consistent.

Currently, union types are encoded as js objects that would look like this:
 { "ctor": "Tag", "_0": "first value", "_1":"second value", ... }  if
serialized.
That looks reasonable to me.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Multiple views sharing the same state?

2017-03-03 Thread Peter Damoc
You can pass the common information to the individual Elm components as
flags.
You could also wire the components by connecting their ports in such a way
that one component could push state and that state be sent to the rest of
the components.

On Fri, Mar 3, 2017 at 3:56 PM, Eirik Sletteberg 
wrote:

> Another use case for a migration from JS app to Elm app; You rewrite one
> view JS -> Elm, and then another view, and so on, and then some components
> on the page are JS views, some are Elm views. But if there is state in Elm,
> it would be desirable for all the views to share the same state (for
> example session/user state). Is that possible?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Sending tagged unions through ports

2017-03-03 Thread Peter Damoc
On Fri, Mar 3, 2017 at 4:38 PM, Brian Hicks  wrote:

> It makes sense (at least to me) that this isn't supported. Elm has a much
> different type system than JavaScript.
>

I respectfully disagree.
It makes sense to focus on other issues that are more important BUT, people
are having enough troubles with boilerplate introduced by decoders that
this could easily be considered a priority.
The fact that Elm and JS have vastly different type systems is irrelevant.
JS wanting to talk with Elm through ports could conceivably use the proper
encoding or some kind of help functions that would create the proper types.

It makes very little sense to force programmers to write code about
something that the compiler already knows.
Sure, keep the encoding and decoding libraries for situations when custom
processing is required BUT, if the marshaling process can be automated, it
should be automated.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Sending tagged unions through ports

2017-03-03 Thread Peter Damoc
On Fri, Mar 3, 2017 at 3:08 PM, Eirik Sletteberg 
wrote:

> An example use case for this would be when gradually porting an existing
> Redux-based app to Elm.
> One could rewrite state handling from Redux into Elm updaters/messages,
> and wrap the Elm app's main updater, so that after every message is passed
> through the updater, it sends the whole state tree through a port, which
> would then be picked up by the legacy application's view (it could consist
> of React components, for example).
> Or one could imagine mapping the state into multiple "ViewModel" objects,
> and dispatch them to different ports (one port per ViewModel type?) but
> whenever you try to send a tagged union type, there's no support for that
> yet.
>
> What you seam to want is automated marhalling and unmarshalling of tagged
unions. This is not yet possible.
You can achieve the functionality you want but you will have to write your
own encoders and decoders and have the tagged unions travel the border as
String or Value.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] can't understand compiler error

2017-02-22 Thread Peter Damoc
In Elm you don't have statements, only expressions and the if model.flag ==
True then expression was not completed. It needs the else branch

You cannot update the model in the view, only in update.





On Wed, Feb 22, 2017 at 8:08 PM, Anurup Mitra 
wrote:

> Hello!
>
> Disclaimer : I am not a programmer and don't understand computer science
> terms. The only formal education that I have had with programming is BASIC
> (school) and C (college - can't remember most of it :-p). Javascript seems
> clumsy and I came across Elm and tried learning it. Was working through the
> Elm tutorial and tried adding some of the extra suggested stuff in the
> "Forms" section of the Tutorial to test my own understanding.
>
> Tried compiling the following code. Idea is to validate form on pressing
> the Submit button.
>
> import Html exposing (..)
> import Html.Attributes exposing (..)
> import Html.Events exposing (onInput, onClick)
> import String
>
> main =
>   Html.beginnerProgram { model = model, view = view, update = update }
>
> -- MODEL
>
> type alias Model =
>   { name : String
>   , age : String
>   , password : String
>   , passwordAgain : String
>   , flag : Bool
>   }
>
> model : Model
> model =
>   Model "" "" "" "" False
>
> -- UPDATE
>
> type Msg
> = Name String
> | Password String
> | PasswordAgain String
> | Age String
> | SetFlag
>
> update : Msg -> Model -> Model
> update msg model =
>   case msg of
> Name name ->
>   { model | name = name }
>
> Age age ->
>   { model | age = age}
>
> Password password ->
>   { model | password = password }
>
> PasswordAgain password ->
>   { model | passwordAgain = password }
>
> SetFlag ->
>   { model | flag = True }
>
> -- VIEW
>
> view : Model -> Html Msg
> view model =
>   div []
> [ input [ type_ "text", placeholder "Name", onInput Name ] []
> , input [ type_ "text", placeholder "Age", onInput Age ] []
> , input [ type_ "password", placeholder "Password", onInput Password ]
> []
> , input [ type_ "password", placeholder "Re-enter Password", onInput
> PasswordAgain ] []
> , div [] [button [ onClick SetFlag ] [text "Submit"] ]
> , viewValidation model
> ]
>
> viewValidation : Model -> Html msg
> viewValidation model =
>   if model.flag == True then
> { model | flag = False }
> let (color, message) =
>   if Result.withDefault 0 (String.toInt model.age) == 0 then
>   ("red", "Funny Age")
> else if String.length model.password < 9 then
>   ("red", "Password too short")
> else if model.password == model.passwordAgain then
>   ("green", "OK")
> else
>   ("red", "Passwords do not match!")
> in
>   div [ style [("color", color)] ] [ text message ]
>
> This throws a compiler error as
>
> Detected errors in 1 module.
>
> -- SYNTAX PROBLEM --
> 
>
> I ran into something unexpected when parsing your code!
>
> 68| let (color, message) =
>  ^
> I am looking for one of the following things:
>
> an 'else' branch
>
>
>
> whitespace
>
>
>
>
> I apologise in advance if this is not the correct platform to ask this or
> if Elm is not supposed to be for novices, but I would greatly appreciate
> any inputs regarding this.
>
> Best Regards
> Anurup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] How can you find out why JSON decoding failed?

2017-02-17 Thread Peter Damoc
What does Json.Decode.decodeValue returns?

Can you share some code?






On Fri, Feb 17, 2017 at 7:09 PM, Rex van der Spuy 
wrote:

> Yes - how would I get the Err result?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] How can you find out why JSON decoding failed?

2017-02-17 Thread Peter Damoc
Where is it failing silently?

Are you calling Json.Decode.decodeValue and not getting an Err?


On Fri, Feb 17, 2017 at 6:34 PM, Rex van der Spuy 
wrote:

> Hi Everyone!
>
> I'm trying to decode some JSON from localStorage.
> I'm able to load the JSON into my Elm app but the decoding is failing
> silently.
> Is there some way to find why decoding didn't succeed?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Community version of the elm guide gitbook?

2017-02-17 Thread Peter Damoc
Is it elm-tutorial by any chance?
https://www.elm-tutorial.org/en/01-foundations/06-type-aliases.html


On Fri, Feb 17, 2017 at 5:51 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> I seem to recall there is a community version of this that is more open to
> accepting contributions:
>
> https://guide.elm-lang.org/types/type_aliases.html
>
> Can't find it though... anyone?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Building a Store without boilerplate

2017-01-30 Thread Peter Damoc
On Mon, Jan 30, 2017 at 12:17 PM, Oliver Searle-Barnes 
wrote:

> # Building a Store without boilerplate
>

I don't think that's possible.
Elm is a static language and what you seam to want is dynamic behavior.

The practical way to solve this is to ferry type information and use that
type information to generate the dynamic behavior.
In Elm, this is done with the help of Json.Decode/Json.Encode

This way, you can take a concrete Elm type, convert it to a generic type
like Value or String, do something dynamic based on the info you encode in
this generic type, get a generic result back and convert the result back
into some concrete Elm type.
so you can have something like:

doSomethingDynamic : a -> (a -> Value) -> Decoder b -> b
doSomethingDynamic payload encoder decoder =
...

Have you seen how I have approached the issue in the exploration bellow?
https://github.com/pdamoc/elm-sapling


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Local third-party packages

2017-01-29 Thread Peter Damoc
On Mon, Jan 30, 2017 at 8:48 AM, Lyle Kopnicky  wrote:

> So I wonder if I can use elm-package to install a package from another
> directory, so hopefully the references will work out right?
>

elm-package does not support that BUT, elm-github-install
 was designed for such
contexts.
Add the package manually to your dependencies and then use
elm-github-install to install it.


> when I build my project, because I'm using the default project URL, it
> gets referenced as _user$project$Native_KaTeX, which doesn't match.


You need a valid github project. Default values don't work. So, if you fork
the project and replace the user in that Native function name, you should
be able to compile it just fine.


> Another possibility is given by looking at https://github.com/eeue56/
> take-home/wiki/Writing-your-first-Elm-Native-module. Here the author
> shows some very different boilerplate, which doesn't seem to involve the
> project name in the variable names. I'd have to copy the elm-katex code
> into my own project and tweak it a bit, but that's OK for now as I'll only
> be building/running my project locally for the foreseeable future. Also I'd
> be able to update the version of KaTeX that's embedded in the file.
>

The guide you referenced is for an old way to do Native. That API is
obsolete.


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] I wish ELM could just be used in the browser

2017-01-29 Thread Peter Damoc
On Sun, Jan 29, 2017 at 4:40 AM, Wyatt Benno  wrote:

> Thanks all! I still do not see why ELM can never be compiled directly in
> the browser. A V8 engine compiler for ELM?
> After all it becomes JavaScript right?
>

There is an experimental compiler that does just that: compile Elm in the
browser.
However, to make that reach the level of performance of the installable
compiler requires a large amount of developer time and there are other
things that are more important.


> Elm's benefits are derived from the functional paradigm (no runtime
> errors, static types, optimized speed, etc.).
> They are trying to make JavaScript more functional, and if used in this
> way there are little differences with the benefits of Elm other than
> developer preference and ease of learning; However since JavaScript runs in
> the browser it will always be more accessible to most people.
>

Do you think that a developer would have troubles installing the tools of
the language that he is developing in?

1) What if I want a header done in Elm, and then a footer with different
> function done in Elm but with a standard HTML center. If I compiled two elm
> files and connected them to the header and footer they would both contain
> overlapping dependencies.
>

You can compile two modules into the same file and use one in the header
and one in the footer. No problem there.


> 2) HTML in ELM looks like div[][div[class "this"][text "does not read
> well"]]. This would not make sense to most team members "designers", anyone
> who does not no ELM. This would mean that developers would need to manually
> change any HTML portion that needs to be in ELM. I could not argue on the
> point that JSX is easier to work with for most people because it looks like
> plain old HTML.
>

elm-html is very easy to pick up. It's a direct mapping. A designer that
know HTML can learn and adapt their knowledge within the hour.


3) When there is an update we would need to go through the entire project
> and fix everything for the new version of Elm.
> I wonder how NoRedInc deals with this.
>

New versions of Elm change things but most changes are small and they
improve things. The core of the language is made of a set of small and
powerful ideas and those are rock solid. Most changes are at the periphery.
Take the removal of FRP. With the move to 0.16 The Elm Architecture became
a standard and with people adopting it, it meant that most of the hairy
Signal code was delegated to the periphery.  The core of the app code was
just types and functions.
When the Signals were removed, for most people, of the update process was a
matter of deleting addresses from the view and adapting some update code.
And the compiler got your back giving you a TO DO list that you could see
getting smaller and smaller.

This was the biggest change to the language since its creation and people
were able to update the code base within a day or so.
Contrast that with the change from python 2 to python 3 or ng1 to ng2.


> I want to use ELM more in production, it is just really hard to make the
> case for it right now. Evan seems busy with a few specific issues at one
> time, so I expect progress will be slow. Dropping FRP was a great start to
> accessibility!
>
> Very good hobby language, I hope I can use it in production soon.


It can be used in production right now but it is not ready for early
majority.
We are still in the early adopters phase.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] I wish ELM could just be used in the browser

2017-01-28 Thread Peter Damoc
Elm was designed to help with reliability and maintainability of large
scale apps.

If it is a toy app or if reliability and maintainability are not important
enough, other technologies are more appropriate.

It depends on what you want to optimize on.

If however reliability and maintainability are important, the time it takes
to learn Elm will be payed back manyfold as the app grows.




On Sat, Jan 28, 2017 at 4:53 PM, Wyatt Benno  wrote:

> I love ELM to work with, but it is too bad it cannot be more direct. I had
> a project come up where ELM could have been used in production but React
> won because it is just js, browser read, and very easy for anyone to start.
> Import React start using it anywhere with or without ports. i wish I could
> import elm in the same way. Any plans for this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Using Elm on the server (full stack Elm webapps )

2017-01-27 Thread Peter Damoc
On Fri, Jan 27, 2017 at 4:51 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Friday, January 27, 2017 at 10:15:49 AM UTC, Rupert Smith wrote:
>>
>> I think what is missing is DB access.
>>
>
> What would be even cooler is if you didn't need to worry about the
> database. If there was a way of declaring a Model in Elm, and every time
> you make an update to it, it automatically gets saved to the database, no
> need invoke a port to save it. I've always though a language which has
> persistence built in would be really cool. It could be done with Elm using
> the same trick as the time travelling debugger - just spool all the updates
> to disk and they form an 'event source' to recover the state from in the
> event of a crash. Occasionally you would check-point the entire state model
> to disk to make a fast recovery point.
>
> Well... this is what I'm looking into right now. Nobody wants to write
boilerplate. :)

The idea would be for the page to interact with a client-side database like
entity that would take care of all the communication with the server.

This is a complex topic. For example, I still have no idea how could one
express relational data in Elm?
e.g. Users have Messages and Messages have other Messages as replies and
each of those Messages have Users. How would you model that in Elm?

I started a topic back in October but I haven't followed it through and now
it has almost completely vanished from my mind.
I'll go again through that discussion and think some more on this.





-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Using Elm on the server (full stack Elm webapps )

2017-01-26 Thread Peter Damoc
On Thu, Jan 26, 2017 at 6:40 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> Still, its a long way from there to a full stack...
>
> Every journey has to start somewhere. Can you share a set of requirements
for a full-stack? Like, how would a checklist for your must have and nice
to have features would be?



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Using Elm on the server (full stack Elm webapps )

2017-01-26 Thread Peter Damoc
Hello community,

I thought that using elm on the backend would be hard but it turns out that
it is easy.

I took the websockets example and turned it into a stand alone webapp.
https://github.com/pdamoc/elm-sapling

The approach that I used is to describe an API between the client and the
server.

This API uses types for Requests that the client sends to the server and
for Responses that the server replies with. The types are imported in both
the server and the client.
The API file also takes care of serialization of the communication.

The server code is then compiled to a js file that is launched with the
help of a small express+ws wrapper.

The client code is compiled into an index file that will be served by
express.

What do you think?

I'm wondering if there is any interesest in creating a full-stack solution
for Elm.
I'm not able to do this alone but maybe a small SIG could create such a
thing.





-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Module / Payload Splitting - Such a thing?

2017-01-26 Thread Peter Damoc
On Thu, Jan 26, 2017 at 5:00 PM, Dave Rapin  wrote:

> Just wondering if there's a good approach for this in Elm? Is there a way
> to split framework code & app code, or are we stuck with adding 100k to our
> payload every time we iterate?
>
> This is being worked on right now and something will be available in 0.19

Also, it is worth notting that a gzipped minified "Hello, World" that
contains the runtime is around 20k (minified and gzipped).



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Super-unimportant request for Google Closure Compiler.js compatibility

2017-01-26 Thread Peter Damoc
You need the --assume_function_wrapper flag.

Also, if you have more troubles you could also drop the compilation level
to SIMPLE. The difference should be no larger than few kb in gzipped form.

It is worth mentioning that at such small sizes, even the unminified output
gzips to very tiny sizes.
In other words, having gzip enabled on the webserver would do more for the
transfer size than even the most aggressive minimizer.





On Thu, Jan 26, 2017 at 9:56 AM, Ahmed Fasih  wrote:

> This is a super-low-priority request: could the Elm compiler emit the
> following line at the end of its JS output:
>
> window['Elm'] = Elm;
>
> I’m used to using Google Closure Compiler after Clojure so I tried it with
> my tiny ~400 LOC Elm app, and without this line above, the `Elm` object
> gets renamed and unavailable in the browser. The line functions as an
> “export” Closure Compiler lingo [1].
>
> With this in place, if I run
>
> $ elm-make Main.elm --output=main.js
> $ yarn add google-closure-compiler-js -dev
> $ yarn run google-closure-compiler-js --compilationLevel ADVANCED main.js
>
> and pipe the result to a minified file, the original Elm-produced JS goes
> from 268 KB to an 80 KB file and my app works flawlessly. (Another data
> point: uglify-js produces a 164 KB minified file.)
>
> --
>
> A couple of further notes, if anyone else is interested in adding Google
> Closure Compiler to their workflow.
>
> It takes 30~ seconds to run advanced compilation on my little app, so I
> have two HTML files: (1) an ephemeral dev.html that loads the original
> Elm-emitted JS and (2) a real index.html that loads the compiled version.
> During development, I just look at dev.html to see my changes quickly.
>
> Besides the compilation time, another reason not to use the compiled code
> during development is that record field names get minified. E.g., I have a
> quick `text (toString model)` and:
>
> - original: `{ err = "", token = "eyJ...", target = Just { target = "冫",
> pos = 1` ...
> - compiled: `{ ba = "", S = "eyJ...", target = { a = "Just", b = { target
> = "冫"` ...
>
> I have a little build script that tacks on the export to the Elm-emitted
> JS, makes the dev.html out of index.html, and kicks off the Closure
> Compiler. It sounds heavy but the script is really short: see [2].
>
> [1] https://developers.google.com/closure/compiler/docs/api-
> tutorial3#export
> [2] https://github.com/fasiha/kanji-abecedario/blob/gh-pages/build.sh and
> the `min` task is of course in `package.json` but it’s not bad either.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Composing Things in Elm

2017-01-25 Thread Peter Damoc
On Wed, Jan 25, 2017 at 8:17 AM, Maksim Demin  wrote:

> Thanks for the response, it totally works, and I definitely think it is
> cleaner than having to Html.map everything! I am still trying to fully
> understand what is going on, pretty new to Elm. I kinda get what you are
> doing in the update to map the command,
>
> ( { model | field2 = "2" }, Cmd.map cfg.lift pageTwoCmd )
>
> but how does that happen in the view? How does this cfg.lift which is lift
> : Page1Msg -> msg work here?
>
> div [ onClick (cfg.lift <| DoSomething1) ] [ text model.field2 ]
>

Sorry about that, my bad. It should have been

div [ onClick (cfg.lift DoSomething1) ] [ text model.field2 ]

basically, the view receives a function that knows how to lift the messages
of the SubModule to the message of the parent. If you have type defined as

type Msg
= Msg1 Page1Msg

Msg1 is also a value constructor, in other words, a function that takes a
Page1Msg and outputs a Msg. This is why you can use it as cfg.lift


Now, the reason my code looked like that was because it started as:

 div [ onClick (cfg.lift << DoSomething1) ] [ text model.field2 ]

and when I saw that not working, my mind produced the version with the <|
(my mind is weird sometimes)

You need << (function composition) when the event handler receives a
function.
So, if you have a submodule message like `type Msg = UpdateNameField
String` and in the view you have an input event, it would look like

input [onInput (cfg.lift << UpdateNameField)] []

if cfg.lift is *f* and UpdateNameField is *g*, then (cfg.lift <<
UpdateNameField) is *h* so that h(a) = f(g(a))

I remember being new to Elm and finding function application (*<|* and* |>*
) and function composition ( *<<* and *>>*) mystifying.
After seeing few more examples and reading through these functions
documentation
 my
mind clicked and now I love them.
They can make the code very very readable.




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   >