[elm-discuss] Re: Emphasizing /r/elm more

2017-01-17 Thread Tomáš Znamenáček
Sorry if this is an offtopic direction, but I (as a newcomer) would also 
like Discourse best. It has an e-mail interface, very good UI, spam 
controls, trust system, community moderation tools, healthy development 
speed, and could be installed under a custom domain name (like 
discuss.elm-lang.org) to give it more visibility. I think it could be a 
good fit both for newbies and advanced users. It would probably need some 
money to run (be it a separate server or hosted instance), but I think we 
could easily raise that.

If solving the two forums situation by introducing a third one (and maybe 
deprecating the first two) is out of the question, just tell me.

T.

-- 
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] OK, or very very wrong?

2017-01-17 Thread Nick H
Your particular example can be rewritten easily to not use functions (and
with even less duplication):

type Msg
= Add Int

view model =
div []
[ button [ onClick (Add -1) ] [ text "-" ]
, div [] [ text (toString model) ]
, button [ onClick (Add 1) ] [ text "+" ]
]

update msg model =
case msg of
Add delta ->
model + delta


On Tue, Jan 17, 2017 at 11:31 PM, Nick H  wrote:

> I would come down on the side of very very wrong. Functions can't be
> converted into strings, and they can't be checked for equality. So if you
> need to debug your program (say, with the interactive debugger), There is
> no way to examine the data being passed in your commands.
>
>
> On Tue, Jan 17, 2017 at 7:24 PM, Marshall handheld Flax <
> m.droid.f...@gmail.com> wrote:
>
>> Is it wrong for Cmds to contain functions (as opposed to data within
>> constructors)?  If it is a reasonable practice, it would allow for more
>> functional component-like modules, but does this violate the Elm
>> architecture?  If it does, is it explicitly mentioned in the docs -- I
>> don't remember seeing it. Here's http://elm-lang.org/examples/buttons
>> rewritten in the Cmd-contains-functions style. Thank you!
>>
>> module Main exposing (..)
>>
>> import Html exposing (beginnerProgram, div, button, text)
>> import Html.Events exposing (onClick)
>>
>> main =
>> beginnerProgram { model = 0, view = view, update = update }
>>
>> type Msg
>> = Transform (Int -> Int)
>>
>> view model =
>> div []
>> [ button [ onClick (Transform ((+) -1)) ] [ text "-" ]
>> , div [] [ text (toString model) ]
>> , button [ onClick (Transform ((+) 1)) ] [ text "+" ]
>> ]
>>
>> update msg model =
>> case msg of
>> Transform xform ->
>> xform model
>>
>>
>> --
>> 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.


Re: [elm-discuss] OK, or very very wrong?

2017-01-17 Thread Nick H
I would come down on the side of very very wrong. Functions can't be
converted into strings, and they can't be checked for equality. So if you
need to debug your program (say, with the interactive debugger), There is
no way to examine the data being passed in your commands.


On Tue, Jan 17, 2017 at 7:24 PM, Marshall handheld Flax <
m.droid.f...@gmail.com> wrote:

> Is it wrong for Cmds to contain functions (as opposed to data within
> constructors)?  If it is a reasonable practice, it would allow for more
> functional component-like modules, but does this violate the Elm
> architecture?  If it does, is it explicitly mentioned in the docs -- I
> don't remember seeing it. Here's http://elm-lang.org/examples/buttons
> rewritten in the Cmd-contains-functions style. Thank you!
>
> module Main exposing (..)
>
> import Html exposing (beginnerProgram, div, button, text)
> import Html.Events exposing (onClick)
>
> main =
> beginnerProgram { model = 0, view = view, update = update }
>
> type Msg
> = Transform (Int -> Int)
>
> view model =
> div []
> [ button [ onClick (Transform ((+) -1)) ] [ text "-" ]
> , div [] [ text (toString model) ]
> , button [ onClick (Transform ((+) 1)) ] [ text "+" ]
> ]
>
> update msg model =
> case msg of
> Transform xform ->
> xform model
>
>
> --
> 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.


[elm-discuss] [early prototype] Elm-Data: a server loading code generator

2017-01-17 Thread Max Goldstein
Hi everyone,

I've been thinking for several months now about a useful abstraction for 
loading data from the server. It's painful to work with HTTP and JSON 
directly because you lack: caching, logic to not send a request already in 
flight again, error handling, and so on.

I came upon the idea that the client (that's you) will provide a type alias 
for each resource's attributes (and perhaps other crucial information), and 
I could generate code that would retrieve resources of those types. 
Generating code also allows the tool to create JSON encoders and decoders, 
a common pain point.

Each resource gets its own module with a standard set of functions. I've 
split out loading a resource (making a request if one is necessary) from 
getting a resource (obtaining it immediately from information available, if 
possible). Keeping track of what's been loaded requires an opaque Store 
model and StoreUpdate message.

I don't have this anywhere near usable yet; I haven't started working on 
the generating part of this at all. I first want to write the code I want 
to be generated by hand, and get feedback on that. Does this approach seem 
okay? Are there any problems you can envision? What you be good to work on 
next?

Have a look here:

https://github.com/mgold/elm-data/tree/master

-- 
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: YAML lib for Elm?

2017-01-17 Thread fxmy wang
Indeed, latest YAML spec is 84 pages long =(   silent screaming).

And I'm not using Jekyll at all, it's just commentit.io stores comments
in Jekyll compatible way.

Thanks for mentioning the Combine package though, will see what I can do =)

Cheers.

2017-01-18 0:09 GMT+08:00 Brian Hicks :

> Creating a YAML parser is going to be a ton more work than you bargained
> for. That spec is hairy! That said, it probably would be the best way.
>
> But there are workarounds! Since you're rendering the YAML in Jekyll
> anyway, is there a conversion function to JSON you could use? Or, could you
> add a step in your build process to convert the comments as files to load?
>
>
> On Jan 17, 2017, 8:51 AM -0600, Zinggi , wrote:
>
> Probably not the answer you'd like, but there doesn't exist one.
> Please do us all a favor and create one yourself ;) (probably with the
> help of this
> .)
> If that's too much effort, you can use some JS lib
>  and use ports to bring it over to
> elm.
>
>
> On Tuesday, 17 January 2017 13:44:41 UTC+1, fxmy wang wrote:
>>
>> Well short story would be: I need to parse some yaml. =)
>>
>> Long version: I'm using commentit.io for storing comments on my handmade
>> blog (powered by Elm of course). And commentit.io stores comments
>> the jekyll way. Hence in format of yaml like this
>> .
>>
>> So I need a way to parse and display comments for my blog.
>>
>> Cheers.
>>
>> 2017-01-17 10:12 GMT+08:00 Brian Hicks :
>>
>>> It doesn't look like there is, unfortunately. What are you trying to
>>> accomplish? Maybe there's another way around. :)
>>>
>>>
>>> On Monday, January 16, 2017 at 12:00:45 AM UTC-6, fxmy wang wrote:

 Hello guys,
 Is there any yaml parser existing for Elm?

 Cherrs.

>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Elm Discuss" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/elm-discuss/s8dy6zlQaYM/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> elm-discuss...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
> To unsubscribe from this group and all its topics, 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 a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


[elm-discuss] Re: Emphasizing /r/elm more

2017-01-17 Thread Matthieu Pizenberg
I would also like to keep something like this group. The fact that every 
one get a chance to be read by the community (without being downvoted or 
just ignored) is very important. A few times in Stack Overflow I have asked 
somewhat hard/specific questions with nobody caring answering it because it 
wasn't popular. I fear that Reddit might be the same. But I'm not a Reddit 
user so I don't know.

Also agree with many elm-discuss arguments given including (but not 
exclusively) :
 - visibility of what I have already read
 - getting emailed when there is an answer in a discussion I'm in
 - real people names 

I strongly feel that the wealth of this discussion group is due to the fact 
that the community likes it, and of course thanks to the great spam 
filtering done for first posts. So encouraging people to change to reddit 
might no be a good idea. If the spam really is a problem, is there a 
mecanism to involve more the community for this control?

In my opinion, the active community here is very useful and I would have 
loved to be redirected here earlier than I was. I only knew about the elm 
slack initially. And may be the same for some newcomers from reddit who 
don't know about this group?

-- 
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] Convert String to symbol (previously `Text.fromString`, like Haskell's `read`)

2017-01-17 Thread Nick H
I'm not sure such a feature would have any uses. Right now, all Elm
functions have well-typed return values.

Ports are the one place where a type annotation is used to enforce a type
at runtime. So I suppose ports are Elm's analog to "read". There has been
lots of discussion about improving ports, to translate JavaScript objects
into ADTs. It's possible that change might happen at some point.


On Tue, Jan 17, 2017 at 9:07 AM, Josh Szmajda  wrote:

> Ah yes this makes sense, we'd need the explicit type annotation. Has that
> functionality been discussed? I know I saw a talk where Evan mentioned
> adding features to the language over time intentionally to help drive
> adoption.
>
> Thanks!
>
> On Monday, January 16, 2017 at 9:06:50 PM UTC-5, Nick H wrote:
>>
>> I doubt such a function will be introduced any time soon, because it's
>> not a properly typed operation. In Haskell, you have to add the type
>> annotation to the function call because read's return type is ambiguous.
>> However, Elm doesn't have any similar ability.
>>
>> For converting Strings to numeric types, there are String.toInt and
>> String.toFloat.
>>
>> For doing what your example does, I might consider using a dictionary
>> mapping strings to states. Maybe Something like:
>>
>> viewStates = Dict.fromList [ ("ViewDocList", ViewDocList),
>> ("ViewDocument", ViewDocument) ]
>>
>> locationUpdate location =
>>   case Dict.get location viewStates of
>> Just state ->
>>   ViewState state
>>
>> Nothing ->
>>   App.NoOp
>>
>> You still need to manually associate strings with view states, but now
>> locationUpdate has the form you want.
>>
>> On Mon, Jan 16, 2017 at 12:44 PM, Josh Szmajda  wrote:
>>
>>> Hey folks!
>>>
>>> This is in reference to https://github.com/elm-lang/core/issues/805
>>>
>>> I'm looking for a function to convert a String to an internal symbol
>>> (signature `String -> a`). Previously this was in `Text.fromString` but
>>> apparently that has been removed.
>>>
>>> The use-case I have in mind is this router:
>>>
>>> ```
>>> locationUpdate : Navigation.Location -> App.Msg
>>> locationUpdate location =
>>>   case (String.dropLeft 2 location.hash) of
>>>
>>> "ViewDocList" -> ViewState ViewDocList
>>>
>>> "ViewDocument" -> ViewState ViewDocument
>>>
>>> _ -> App.NoOp
>>>
>>> -- Would rather code this as:
>>> -- case Text.fromString msg of
>>> --   Just value -> ViewState value
>>> --   Nothing-> App.NoOp
>>> ```
>>>
>>> In Haskell this would be `read`:
>>>
>>> ```
>>> Prelude> read "4.5" :: Float
>>> 4.5
>>> Prelude> :t read "4.5" :: Float
>>> read "4.5" :: Float :: Float
>>> ```
>>>
>>> Any ideas on when this might come back?
>>>
>>> Thanks!
>>> -Josh
>>>
>>> --
>>> 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...@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.
>

-- 
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] Re: Image lazy-loading?

2017-01-17 Thread Tomáš Znamenáček
Now that I think of it, this is even more tricky, right? Because the Elm 
runtime juggles the DOM nodes as it sees fit, easily making them go out of 
sync with the Echo.js library. So what should I do to make images 
lazy-load? Thank you,

T.

-- 
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] Convert String to symbol (previously `Text.fromString`, like Haskell's `read`)

2017-01-17 Thread Josh Szmajda
Ah yes this makes sense, we'd need the explicit type annotation. Has that 
functionality been discussed? I know I saw a talk where Evan mentioned 
adding features to the language over time intentionally to help drive 
adoption.

Thanks!

On Monday, January 16, 2017 at 9:06:50 PM UTC-5, Nick H wrote:
>
> I doubt such a function will be introduced any time soon, because it's not 
> a properly typed operation. In Haskell, you have to add the type annotation 
> to the function call because read's return type is ambiguous. However, Elm 
> doesn't have any similar ability.
>
> For converting Strings to numeric types, there are String.toInt and 
> String.toFloat.
>
> For doing what your example does, I might consider using a dictionary 
> mapping strings to states. Maybe Something like:
>
> viewStates = Dict.fromList [ ("ViewDocList", ViewDocList), 
> ("ViewDocument", ViewDocument) ]
>
> locationUpdate location =
>   case Dict.get location viewStates of
> Just state ->
>   ViewState state
>
> Nothing -> 
>   App.NoOp
>
> You still need to manually associate strings with view states, but now 
> locationUpdate has the form you want.
>
> On Mon, Jan 16, 2017 at 12:44 PM, Josh Szmajda  > wrote:
>
>> Hey folks!
>>
>> This is in reference to https://github.com/elm-lang/core/issues/805
>>
>> I'm looking for a function to convert a String to an internal symbol 
>> (signature `String -> a`). Previously this was in `Text.fromString` but 
>> apparently that has been removed.
>>
>> The use-case I have in mind is this router:
>>
>> ```
>> locationUpdate : Navigation.Location -> App.Msg
>> locationUpdate location =
>>   case (String.dropLeft 2 location.hash) of
>>
>> "ViewDocList" -> ViewState ViewDocList
>>
>> "ViewDocument" -> ViewState ViewDocument
>>
>> _ -> App.NoOp
>>
>> -- Would rather code this as:
>> -- case Text.fromString msg of
>> --   Just value -> ViewState value
>> --   Nothing-> App.NoOp
>> ```
>>
>> In Haskell this would be `read`:
>>
>> ```
>> Prelude> read "4.5" :: Float
>> 4.5
>> Prelude> :t read "4.5" :: Float
>> read "4.5" :: Float :: Float
>> ```
>>
>> Any ideas on when this might come back?
>>
>> Thanks!
>> -Josh
>>
>> -- 
>> 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...@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.


[elm-discuss] Re: elm-style-animation awesomeness

2017-01-17 Thread Rex van der Spuy
Agreed, for me it's really one of Elm's killer apps.
`elm-style-elements` is just as awesome:

http://package.elm-lang.org/packages/mdgriffith/style-elements/latest

It has pretty much "solved" CSS, in the same way that Elm solved JavaScript.

-- 
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] Image lazy-loading?

2017-01-17 Thread Tomáš Znamenáček
Hello!

I have an app that’s heavy on images and need to load the images only as 
they become visible. I would like to use a simple drop-in JavaScript 
library to do that:

https://github.com/toddmotto/echo

The library is loaded like this:



echo.init({…});


The initialization code finds all images with a certain data attribute and 
sprinkles some lazy-loading pixie dust on them. The obvious catch is that 
if Elm changes the DOM afterwards, there may be new lazy-loaded images 
which the Echo.js library doesn’t know about. What can I do? Is there some 
kind of hook that would let me know about DOM changes?

T.

-- 
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] elm-style-animation awesomeness

2017-01-17 Thread 'Rupert Smith' via Elm Discuss
Just wanted to express my delight with mdgriffith/elm-style-animation. I 
haven't done much with animating HTML before, but half a day in and I 
already feel like its a breeze. I see there is 
elm-community/easing-functions too. I'm trying to follow the advice in the 
Material Design Spec, and its going to be a lot easier than I thought.

-- 
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] Re: Elm events 2017

2017-01-17 Thread Matthieu Pizenberg

Hi,

Just to say that there is one meetup in Paris tomorrow: 
https://www.meetup.com/Meetup-Elm-Paris/events/236216040/
It seems to be already full though.

There is another one in Amsterdam 1st of February: 
https://www.meetup.com/Elm-Amsterdam/events/236942429/
Kind of a hacking night. 15 spots still available now.


On Friday, January 6, 2017 at 9:08:54 PM UTC+1, Rupert Smith wrote:
>
> On Friday, January 6, 2017 at 5:56:35 PM UTC, Josh Adams wrote:
>>
>> Both of my talks at NDC London in a couple of weeks involve Elm: 
>> http://ndc-london.com/speaker/josh-adams
>>
>
> Just trying to figure out what NDC is about:
>  
> "About NDC
>
> Since its start-up in Oslo 2008, the Norwegian Developers Conference (NDC) 
> quickly became one of Europe`s largest conferences for .NET & Agile 
> development. Today NDC Conferences are 5-day events with 2 days of 
> pre-conference workshops and 3 days of conference sessions."
>
> Is it very agile + .Net focused still? What is the overall theme of this 
> event?
>
>

-- 
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 "faster than JavaScript" (version 0.18) - NOT - Parts I and II...

2017-01-17 Thread OvermindDL1
On Saturday, January 14, 2017 at 3:13:40 PM UTC-7, GordonBGood wrote:
>
> I saw that over on elm-dev, but haven't tried it because compilation speed 
> isn't a problem for the Elm code I have written so far.  The only reason I 
> brought it up is OvermindDL1's comment 
>  that 
> compiling a Ocaml/BucketScript code (that presumably did the same thing as 
> the Elm code) took about 0.1 seconds as compared to 40 seconds with the Elm 
> compiler - a 400 times speed-up!  We weren't given details of the code or 
> test conditions and whether one was an incremental compilation, but that 
> sounds quite serious and would affect the usability of Elm.  If that data 
> is verifiable, a speed up of double or even quadruple doesn't begin to 
> touch the difference and should be investigated.
>

It was a rewrite of a messaging system at work, it was in elm but we had 
issues that necessitated the use of too many ports, the new one written in 
OCaml (transpiled to javascript by Bucklescript) does the same thing in 
about the same lines of code, except no javascript was used at all.  The 
lines of code is hovering around 6k for both versions, a compile for both 
is done just by calling elm-make or bsb respectively and those are the 
output times for a clean compile (no cache for either) with both spread 
across about 31 source files.  I'm not sure why the elm compilation is so 
slow, the compilation is happening on Windows so that could be a factor. 
 And sadly no, cannot release work code without consent.  ;-)

A note though, the elm code was severely hampered by the type system in Elm 
(lack of HKT's or HPT's) so had to get creative with use of records and 
unions, so it is entirely possible we hit a very slow case, in the OCaml 
code we used some GADT's and polymorphic modules so as to not resort to 
those hacks.


On Saturday, January 14, 2017 at 9:14:55 PM UTC-7, Richard Feldman wrote:
>
> If only there were a binary posted somewhere, based on a compiler that had 
> just been rewritten to improve build times, so that someone could post a 
> benchmark instead of speculation! ;)


I might be able to test out the new compiler, still have the old elm code 
in the repo (just that chunk is unused, we are still using other parts of 
Elm that are not as large and not as full-of-ports) if really curious? 


On Sunday, January 15, 2017 at 8:21:28 PM UTC-7, Richard Feldman wrote:
>
> you need recompile that module and regenerate a monolithic js file, the 
>> larger project it gets , the worse compilation time you get in elm mode. If 
>> you have experience in C++, you know the bottle neck used to be linking, it 
>> is quite common for a c++ project to spend 20minutes in linking.
>
>
> Considering Evan is working on asset management for the next release, I 
> doubt "compile everything to one file" will be true after it lands. (That 
> release is presumably still several months away; this is just speculation 
> on my part.)
>

Ooo, now that would be awesome.  :-)


On Tuesday, January 17, 2017 at 4:25:08 AM UTC-7, Rupert Smith wrote:
>
> Yes, that is what I thought. I probably missed some context out when 
> quoting, but my question was in response to OvermindDL1's suggestion that 
> moving to OCaml would open up the possibility of compiling to different 
> back-ends other than javascript.
>
> An alternative might be to re-write the Native modules in the Elm core in 
> OCaml. There isn't a huge amount of it.
>

Precisely this, I've already done quite a large chunk of it as a test and 
it translates very easily (and becomes type safe, which Elm's is not as 
I've hit 'undefined's in pure elm code before (already in the bug tracker, 
but why did they happen at all?!)).  I kept it identical to the Elm API as 
well, though if I broke Elm's API in a couple of minor ways then I could 
*substantially* reduce the number of allocations done...  But yes, I've 
rewrote most of Elm's native Core code as well as some third-party 
libraries like navigation, all without a touch of javascript and all of it 
type safe the whole way, mostly playing around but we ended up using a lot 
of it at work anyway (I still need to get around to cleaning it up and 
releasing it...).  An Elm->OCaml transpiler is entirely possible and I've 
no doubt it would take substantially less than a year to do (if I could get 
my work to pay for it I'd guess probably two weeks at most, though if 
everything goes well I'd guess two days for the language conversion and the 
rest on filling out the rest of the API that I've not yet done so as to 
remove all javascript, which would make it compileable to native code as 
well once system checks were added in, another chunk of time for that but 
not 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 

Re: [elm-discuss] Re: YAML lib for Elm?

2017-01-17 Thread Brian Hicks
Creating a YAML parser is going to be a ton more work than you bargained for. 
That spec is hairy! That said, it probably would be the best way.

But there are workarounds! Since you're rendering the YAML in Jekyll anyway, is 
there a conversion function to JSON you could use? Or, could you add a step in 
your build process to convert the comments as files to load?

On Jan 17, 2017, 8:51 AM -0600, Zinggi , wrote:
> Probably not the answer you'd like, but there doesn't exist one.
> Please do us all a favor and create one yourself ;) (probably with the help 
> of this (http://package.elm-lang.org/packages/Bogdanp/elm-combine/latest).)
> If that's too much effort, you can use some JS lib 
> (https://www.npmjs.com/search?q=yaml) and use ports to bring it over to elm.
>
>
> On Tuesday, 17 January 2017 13:44:41 UTC+1, fxmy wang wrote:
> > Well short story would be: I need to parse some yaml. =)
> >
> > Long version: I'm using commentit.io (https://commentit.io) for storing 
> > comments on my handmade blog (powered by Elm of course). And commentit.io 
> > (http://commentit.io) stores comments the jekyll way. Hence in format of 
> > yaml like this 
> > (https://github.com/fxmy/fxmy.github.io/blob/master/_data/comments.yml).
> >
> > So I need a way to parse and display comments for my blog.
> >
> > Cheers.
> >
> > 2017-01-17 10:12 GMT+08:00 Brian Hicks  > (javascript:)>:
> > > It doesn't look like there is, unfortunately. What are you trying to 
> > > accomplish? Maybe there's another way around. :)
> > >
> > >
> > > On Monday, January 16, 2017 at 12:00:45 AM UTC-6, fxmy wang wrote:
> > > > Hello guys,
> > > > Is there any yaml parser existing for Elm?
> > > >
> > > > Cherrs.
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to a topic in the 
> > > Google Groups "Elm Discuss" group.
> > > To unsubscribe from this topic, visit 
> > > https://groups.google.com/d/topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
> > > To unsubscribe from this group and all its topics, send an email to 
> > > elm-discuss...@googlegroups.com (javascript:).
> > > For more options, visit https://groups.google.com/d/optout.
> >
>
>
>
> --
> You received this message because you are subscribed to a topic in the Google 
> Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> elm-discuss+unsubscr...@googlegroups.com 
> (mailto: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.


[elm-discuss] Re: Dealing with invalid state transitions

2017-01-17 Thread Tomáš Znamenáček
Wow, thank you very much for the responses! I went with the tuple pattern 
match trick for the moment, it’s better than what I had before.

But I would still be interested in splitting the app in two parts. It feels 
wrong to mix the loading logic with the display logic in a single function. 
Ideally, I would like the app to “behave like a loader” and then switch the 
behaviour completely to the display part, passing the loaded data or an 
error. And the update function running the display part would know nothing 
about data loading. Does that make sense?

Thank you again,

T.

-- 
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] Re: Dealing with invalid state transitions

2017-01-17 Thread Max Goldstein
You could model your data using the RemoteData library on elm-package, and use 
the map function to apply changes only to loaded data. 

-- 
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] Re: Dealing with invalid state transitions

2017-01-17 Thread Zinggi
You could use this trick:

case (state, msg) of
(Displaying stuff, UpdateThis) -> ...
(Displaying stuff, UpdateThat) -> ...
(Loading, _) -> ...
_ -> ... {- only if needed -}


On Tuesday, 17 January 2017 15:03:05 UTC+1, Tomáš Znamenáček wrote:
>
> Hello!
>
> I have an app that loads some JSON from a website and displays it. The 
> state of the app could be modelled a bit like this:
>
> type State =
> Loading |
> Displaying Stuff
>
> type alias Stuff = { … }
>
> Now I am writing the update function to handle messages:
>
> update : Msg -> State -> (State, Cmd Msg)
> update msg state = case msg of
> UpdateThis -> …
> UpdateThat -> …
>
> My problem is that the state can be either Loading or Displaying, but most 
> of the messages only make sense in the Displaying state, leading me to code 
> like this:
>
> update : Msg -> State -> (State, Cmd Msg)
> update msg state = case msg of
> UpdateThis -> case state of
> Displaying stuff -> …
> _ -> (Failed "Invalid state", Cmd.none)
> UpdateThat -> case state of
> Displaying stuff -> …
> _ -> (Failed "Invalid state", Cmd.none)
>
> Obviously, this is dumb. How can I “divide” the loading and the displaying 
> part of the app? (Assuming that UpdateThis and UpdateThat can only arrive 
> in the correct, Displaying state.)
>
> Thank you!
>
> T.
>

-- 
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: YAML lib for Elm?

2017-01-17 Thread Zinggi
Probably not the answer you'd like, but there doesn't exist one.
Please do us all a favor and create one yourself ;) (probably with the help 
of this .)
If that's too much effort, you can use some JS lib 
 and use ports to bring it over to elm.


On Tuesday, 17 January 2017 13:44:41 UTC+1, fxmy wang wrote:
>
> Well short story would be: I need to parse some yaml. =)
>
> Long version: I'm using commentit.io for storing comments on my handmade 
> blog (powered by Elm of course). And commentit.io stores comments 
> the jekyll way. Hence in format of yaml like this 
> .
>
> So I need a way to parse and display comments for my blog.
>
> Cheers.
>
> 2017-01-17 10:12 GMT+08:00 Brian Hicks  >:
>
>> It doesn't look like there is, unfortunately. What are you trying to 
>> accomplish? Maybe there's another way around. :)
>>
>>
>> On Monday, January 16, 2017 at 12:00:45 AM UTC-6, fxmy wang wrote:
>>>
>>> Hello guys,
>>> Is there any yaml parser existing for Elm?
>>>
>>> Cherrs.
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Elm Discuss" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> elm-discuss...@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.


[elm-discuss] Re: Dealing with invalid state transitions

2017-01-17 Thread Matthew Griffith

You could invert your cases.


update msg state =
case state of
   Loading ->
  case msg of
(all your messages that apply when loading)
   Displaying stuff ->
   case msg of
(all your messages that apply when displaying




On Tuesday, January 17, 2017 at 9:03:05 AM UTC-5, Tomáš Znamenáček wrote:
>
> Hello!
>
> I have an app that loads some JSON from a website and displays it. The 
> state of the app could be modelled a bit like this:
>
> type State =
> Loading |
> Displaying Stuff
>
> type alias Stuff = { … }
>
> Now I am writing the update function to handle messages:
>
> update : Msg -> State -> (State, Cmd Msg)
> update msg state = case msg of
> UpdateThis -> …
> UpdateThat -> …
>
> My problem is that the state can be either Loading or Displaying, but most 
> of the messages only make sense in the Displaying state, leading me to code 
> like this:
>
> update : Msg -> State -> (State, Cmd Msg)
> update msg state = case msg of
> UpdateThis -> case state of
> Displaying stuff -> …
> _ -> (Failed "Invalid state", Cmd.none)
> UpdateThat -> case state of
> Displaying stuff -> …
> _ -> (Failed "Invalid state", Cmd.none)
>
> Obviously, this is dumb. How can I “divide” the loading and the displaying 
> part of the app? (Assuming that UpdateThis and UpdateThat can only arrive 
> in the correct, Displaying state.)
>
> Thank you!
>
> T.
>

-- 
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] Dealing with invalid state transitions

2017-01-17 Thread Tomáš Znamenáček
Hello!

I have an app that loads some JSON from a website and displays it. The 
state of the app could be modelled a bit like this:

type State =
Loading |
Displaying Stuff

type alias Stuff = { … }

Now I am writing the update function to handle messages:

update : Msg -> State -> (State, Cmd Msg)
update msg state = case msg of
UpdateThis -> …
UpdateThat -> …

My problem is that the state can be either Loading or Displaying, but most 
of the messages only make sense in the Displaying state, leading me to code 
like this:

update : Msg -> State -> (State, Cmd Msg)
update msg state = case msg of
UpdateThis -> case state of
Displaying stuff -> …
_ -> (Failed "Invalid state", Cmd.none)
UpdateThat -> case state of
Displaying stuff -> …
_ -> (Failed "Invalid state", Cmd.none)

Obviously, this is dumb. How can I “divide” the loading and the displaying 
part of the app? (Assuming that UpdateThis and UpdateThat can only arrive 
in the correct, Displaying state.)

Thank you!

T.

-- 
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] Re: How do I open a URL?

2017-01-17 Thread Tomáš Znamenáček
Thank you very much, the port approach worked well for me.

T.

-- 
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: YAML lib for Elm?

2017-01-17 Thread fxmy wang
Well short story would be: I need to parse some yaml. =)

Long version: I'm using commentit.io for storing comments on my handmade
blog (powered by Elm of course). And commentit.io stores comments
the jekyll way. Hence in format of yaml like this
.

So I need a way to parse and display comments for my blog.

Cheers.

2017-01-17 10:12 GMT+08:00 Brian Hicks :

> It doesn't look like there is, unfortunately. What are you trying to
> accomplish? Maybe there's another way around. :)
>
>
> On Monday, January 16, 2017 at 12:00:45 AM UTC-6, fxmy wang wrote:
>>
>> Hello guys,
>> Is there any yaml parser existing for Elm?
>>
>> Cherrs.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/s8dy6zlQaYM/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


[elm-discuss] Re: External Firebase comms to Elm via ports?

2017-01-17 Thread Bernardo
I'm not sure about the problem that you are trying to solve, but I just 
wanted to mention that the Firebase rest api can stream updates using 
server sent events. 

On Tuesday, 17 January 2017 07:25:59 UTC-3, Marais Rossouw wrote:
>
> So then are you saying I use Firebase's REST api framework? And call the 
> api every second or something for updates?
>
> On Tuesday, January 17, 2017 at 1:59:05 AM UTC+10, Maxime Dantec wrote:
>>
>> The Elm-Kinto library for Mozilla Kinto is using the Http library instead 
>> of trying to wrap the JS library. I think it's smart :)
>>
>> On Monday, January 16, 2017 at 4:45:25 PM UTC+1, Marais Rossouw wrote:
>>>
>>> I have custom Firebase auth processes (Auth0 => Firebase), so I run all 
>>> my login logic using TypeScript with Svelte 
>>> , once I have a successful JWT 
>>> token, either from sessionStorage or from a fresh login, I then boot off my 
>>> Elm app, sending it some JWT, profile info via a Flag. I have its a SPA, 
>>> with a routeing and pages, all componentized and working fine. 
>>>
>>> My only real problem now is comms to firebase, sure, ElmFire exists, but 
>>> how do I just give it an active auth token etc... and without loading 
>>> Firebase for JS and ElmFire for Elm. Just seems like way to many kbs. 
>>>
>>> Is there a nice and efficient way to let Elm port out a "hey listen to 
>>> this ref", with a "hey Elm, I have some new data for you for this ref". 
>>> Ports to tell JS to listen, and subscriptions to tell Elm about new data. 
>>> Without having a port for every listen, and a subscription for every data 
>>> callback.
>>>
>>> Ideally, I'd like my update, to send off a Cmd that accepts a callback 
>>> Msg, the update function to call and a ref. So that way I can store that in 
>>> a List of some sort, and when I get a new data payload from JS, I can loop 
>>> over my List find the item that matches the ref, execute the update, 
>>> sending in the Msg with the string value, so decoding happens on the pages' 
>>> update.
>>>
>>> My code is currently closed source (Github), if anyone is genuinely keen 
>>> to help me out, with a top-notch solution, ill add you to the repo, and 
>>> give you some $$ for your time.
>>>
>>

-- 
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 "faster than JavaScript" (version 0.18) - NOT - Parts I and II...

2017-01-17 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, January 17, 2017 at 5:23:33 AM UTC, GordonBGood wrote:
>
> On Monday, 16 January 2017 21:09:43 UTC+7, Rupert Smith wrote:
>>
>> On Saturday, January 14, 2017 at 1:51:39 AM UTC, GordonBGood wrote:
>>>
>>> All that this would take would be to write an Elm parser into the first 
 stage of the OCaml pipeline? You'd also need to compile the Native 
 modules, 
 is there already some way to feed them into the Ocaml pipeline?

>>>
>>> Elm "Native" libraries are JavaScript, and that is what BuckleScript 
>>> does: as well as output JS code, it also has JS FFI to allow BuckleScript 
>>> code to call to/receive calls from JS code.  I think this would be handled 
>>> by an Elm PP just as OCaml handles FFI references -  leaving FFI blanks to 
>>> be later "filled in" by later passes.
>>>
>>
>> Yes, that is what I was getting at. If you compile Elm -> Ocaml -> 
>> Javascript, then the Native stuff in Elm just gets copied into the output 
>> javascript directly (unless of course passing it through Ocaml is 
>> worthwhile and can optimize it). But if you are going Elm -> Ocaml -> 
>> native x86_64 binary, then the javascript needs to be compiled through 
>> Ocaml. So I was just wondering if the Ocaml tool-chain already has a 
>> javascript front-end for it?
>>
>
> Writing a JavaScript front end for OCaml would be an ambitious undertaking 
> because JavaScript does not resemble OCaml in the least and there wouldn't 
> seem much point:
>

Yes, that is what I thought. I probably missed some context out when 
quoting, but my question was in response to OvermindDL1's suggestion that 
moving to OCaml would open up the possibility of compiling to different 
back-ends other than javascript.

An alternative might be to re-write the Native modules in the Elm core in 
OCaml. There isn't a huge amount of it.

-- 
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] Re: External Firebase comms to Elm via ports?

2017-01-17 Thread Marais Rossouw
So then are you saying I use Firebase's REST api framework? And call the 
api every second or something for updates?

On Tuesday, January 17, 2017 at 1:59:05 AM UTC+10, Maxime Dantec wrote:
>
> The Elm-Kinto library for Mozilla Kinto is using the Http library instead 
> of trying to wrap the JS library. I think it's smart :)
>
> On Monday, January 16, 2017 at 4:45:25 PM UTC+1, Marais Rossouw wrote:
>>
>> I have custom Firebase auth processes (Auth0 => Firebase), so I run all 
>> my login logic using TypeScript with Svelte 
>> , once I have a successful JWT 
>> token, either from sessionStorage or from a fresh login, I then boot off my 
>> Elm app, sending it some JWT, profile info via a Flag. I have its a SPA, 
>> with a routeing and pages, all componentized and working fine. 
>>
>> My only real problem now is comms to firebase, sure, ElmFire exists, but 
>> how do I just give it an active auth token etc... and without loading 
>> Firebase for JS and ElmFire for Elm. Just seems like way to many kbs. 
>>
>> Is there a nice and efficient way to let Elm port out a "hey listen to 
>> this ref", with a "hey Elm, I have some new data for you for this ref". 
>> Ports to tell JS to listen, and subscriptions to tell Elm about new data. 
>> Without having a port for every listen, and a subscription for every data 
>> callback.
>>
>> Ideally, I'd like my update, to send off a Cmd that accepts a callback 
>> Msg, the update function to call and a ref. So that way I can store that in 
>> a List of some sort, and when I get a new data payload from JS, I can loop 
>> over my List find the item that matches the ref, execute the update, 
>> sending in the Msg with the string value, so decoding happens on the pages' 
>> update.
>>
>> My code is currently closed source (Github), if anyone is genuinely keen 
>> to help me out, with a top-notch solution, ill add you to the repo, and 
>> give you some $$ for your time.
>>
>

-- 
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: on reuse and effects/subscriptions

2017-01-17 Thread Peter Damoc
A little bit more context.
I'm trying to use the reuse guide and to reimplement the old
elm-architecture-tutorial examples using the new approach.
I've managed to solve the first 4 on my own but I'm stuck on 5
https://github.com/pdamoc/elm-new-achitecture



On Mon, Jan 16, 2017 at 6:46 PM, Rex van der Spuy 
wrote:

> Thanks for asking this Peter, I've been also been wondering about these
> same things lately.
>
> --
> 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.