Re: [elm-discuss] TypeNats, SafeList and Array-Multidim updated for 0.17

2016-08-22 Thread Janis Voigtländer
I agree with Martin. Do it the way that suits your own organizing best.
(But all else being equal, maybe it is not worth troubling users of your
packages to rename their dependencies.)

As to the original question about there being a guideline against elm-
prefixes in package names: Note that along with Elm 0.17 Evan released
evancz/elm-graphics, not evancz/graphics (but, in line with the
non-repeating of elm- in elm-lang packages: elm-lang/keyboard, not
elm-lang/elm-keyboard, etc.).
​

2016-08-22 14:52 GMT+02:00 Martin Janiczek :

> It depends on how you want to organize your Github, I guess. Your package
> name and repository name must match, so whatever works best for you. For
> example, I have `clj-markov` and `elm-markov` to differentiate the
> different (Clojure and Elm) projects.
>
> On Sunday, August 21, 2016 at 8:41:44 PM UTC+2, Joey Eremondi wrote:
>>
>> Well, that's my bad...
>>
>> Any thoughts on if I should keep the old or new names?
>>
>> On Sat, Aug 20, 2016 at 11:27 PM, Janis Voigtländer <
>> janis.voi...@gmail.com> wrote:
>>
>>> to match the “don’t start with elm-“ guideline
>>>
>>> What guideline is that?
>>>
>>> The elm-lang and elm-community organizations have dropped elm- prefixes
>>> from package names, or are in the process of doing so, because something
>>> like elm-community/elm-list-extra reads strange. I don’t think anything
>>> is wrong or inappropriate with JoeyEremondi/elm-typenats, though.
>>> ​
>>>
>>> 2016-08-21 5:39 GMT+02:00 Joey Eremondi :
>>>
 Hi All,

 I've updated my libraries for 0.17. Nothing changed really for the API,
 but I've changed the naming to match the "don't start with elm-" guideline.

 http://package.elm-lang.org/packages/JoeyEremondi/typenats/1.0.0
 http://package.elm-lang.org/packages/JoeyEremondi/elm-SafeLi
 sts/2.0.0/List-SafeList
 http://package.elm-lang.org/packages/JoeyEremondi/array-mult
 idim/1.0.0/Array-MultiDim

 As always, feedback is welcome.

 In the next iteration, I'd like to make specialized versions of 2d, 3d
 and 4d arrays so people can use them without ever seeing SafeLists.


 --
 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...@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: Hide component on document click

2016-08-22 Thread Francisco Ramos
Hi, OvermindDL1

Thanks a lot. This is exaclty what I need... and great examples. I wasn't 
aware of `elm-mdl` :-)

Fran

On Monday, August 22, 2016 at 5:46:53 PM UTC+2, OvermindDL1 wrote:
>
> For an example look at `elm-mdl`'s Menu.  Basically what it does is use 
> http://package.elm-lang.org/packages/elm-lang/mouse/1.0.0/ to listen to 
> mouse events, and it gets the geometric bound of the menu by using 
> http://package.elm-lang.org/packages/debois/elm-dom/1.0.0/DOM to get the 
> information and if the mouse click is outside of the menu then it sends a 
> message to close the menu.
>
> You could also just use `elm-mdl`'s menu too if you want.  :-)
>
>
> On Monday, August 22, 2016 at 1:52:39 AM UTC-6, Francisco Ramos wrote:
>>
>> Hi there,
>>
>> I'm fairly new with Elm. I'm currently working on a personal project 
>> (Minesweeper, repo here: https://github.com/jscriptcoder/minesweeper-elm) 
>> to learn this fascinating language and architecture. I have this menu that 
>> opens when you click on a link. What I'd like to do is to hide it when you 
>> click away. Not sure what's the best way to do it. I thought about creating 
>> a port that will send a message to Elm on document click. But I'm 
>> wondering: it'll also send this message when I click on the link to open 
>> the menu. Then I'll have to stopPropagation when clicking on this link. Not 
>> sure how to do all this.
>>
>> Any help, suggestion or link to an example would be highly appreciated.
>>
>> Thanks a lot
>>
>> 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.


[elm-discuss] Re: In a select element, how do I designate the initially selected option from my model?

2016-08-22 Thread Gabe Krambs
Brilliant. Thanks!

On Tuesday, August 23, 2016 at 12:04:52 AM UTC-5, Gabe Krambs wrote:
>
> Let's say I have a select element to choose a person, and I want to have a 
> certain person, say with id = 3, to be initially selected. How do I pass 
> this id down into my options, and then set the selected attribute to True 
> in that options?
>
>
> Some sample code:
>
>
> personSelect : List Person -> String -> Html Msg
> personSelect : personList selectedId =
> div []
> [ select [] (List.map personOption personList) ]
>
>
> personOption : Person -> Html Msg
> personOption : person = 
> option [ value (toString person.id) ] [ text person.name ]
>
>
> Specifically, how do I get "selectedId" passed to "personOption"? Can I 
> even do this using List.map?
>
>
> Thanks 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.


[elm-discuss] In a select element, how do I designate the initially selected option from my model?

2016-08-22 Thread Gabe Krambs


Let's say I have a select element to choose a person, and I want to have a 
certain person, say with id = 3, to be initially selected. How do I pass 
this id down into my options, and then set the selected attribute to True 
in that options?


Some sample code:


personSelect : List Person -> String -> Html Msg
personSelect : personList selectedId =
div []
[ select [] (List.map personOption personList) ]


personOption : Person -> Html Msg
personOption : person = 
option [ value (toString person.id) ] [ text person.name ]


Specifically, how do I get "selectedId" passed to "personOption"? Can I 
even do this using List.map?


Thanks 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.


[elm-discuss] Re: Task ports: A proposal to make it easier to integrate JS with Elm.

2016-08-22 Thread Maxwell Gurewitz
I've had the same idea.  Really hope this gets noticed!

On Saturday, August 13, 2016 at 8:31:07 AM UTC-7, James Wilson wrote:
>
> The problem
>
> ports as they stand are fundamentally incompatible with Tasks. Being 
> backed by Cmd's, they are harder to compose. A frustration of mine is that 
> often we are directed to "just use ports" when a proper interface to some 
> native API is not yet available, but this leads to our Msg types growing 
> and more significant changes being required when eventually the proper 
> interface is made available.
>
> Also, many JS interop things I find myself wanting to do are fundamentally 
> one-shot functions which I expect a result back into Elm from immediately, 
> or otherwise just want to compose with other Task based things. Some 
> examples that come to mind of one-shot tasks you may want to compose rather 
> than use the streaming interface that ports provide:
>
>- Getting items from local/sessionStorage
>- .. really, most things involving working with the Web API that arent 
>yet implemented in Elm.
>- Embedding JS widgets into Elm elements
>- Using a JS library for doing things like hashing passwords or 
>obtaining some data back from some custom service
>- Interacting with things like Electron for creating apps that can run 
>in the desktop and interact with the filesystem etc.
>
>
> The solution
>
> Task ports. The idea is that these are defined the same way that Ports in 
> elm currently are, but they return a Task type rather than a Cmd or Sub 
> type. On the JS Side, we attach a function to the Elm app that returns a 
> Promise, and on the Elm side we wait for the Promise returned to reject or 
> resolve, and marhsall the error or result from the promise into the error 
> or result type required by the Task type of the port.
>
> Let's see how this might work:
>
>
> *Ports.elm:*
>
> port apiSession: Task String SessionId
>
>
>
> *Main.elm:*
>
> import Ports
> import Json.Decode as Decode
> import Task exposing (andThen)
>
>
> -- get an API session from JS land and make an http request using it
> -- given some path and a decoder to decipher the result:
> apiRequest : String -> Decoder a -> Task ApiError a
> apiRequest path decoder =
>   let
> headers sessId =
> [ ("Content-Type", "application/json")
> , ("MyApp-SessionId", sessId)
> ]
>
>
> req sessId = Http.send Http.defaultSettings
> { verb = "POST"
> , headers = headers sessId
> , url = path
> }
>
>
> decodeResponse res = Decode.decodeString decoder -- ...handle error 
> etc
>   in
> Ports.apiSession `andThen` req `andThen` decodeResponse
>
>
> *App.js:*
>
> Elm.Main.ports.apiSession = function(){
> return new Promise(function(resolve,reject){
>
>
> var sess = localStorage.getItem("sessionId");
> if(!sess) reject("NO_SESSION");
> else resolve(sess);
>
>
> });
> }
>
> var app = Elm.Main.fullscreen();
>
>
>
>
> Here, we use a tiny bit of JS to access localStorage and pull out a 
> session ID. This function is used whenever the apiRequest Task is performed 
> in Elm, and composes nicely into our apiRequest without the need for a 
> complicated effect manager or threading a sessionId through everywhere just 
> because we need to get it from a Cmd based port.
>
> One of the nice things about this is that there is minimal refactoring to 
> do for those things that do eventually receive coverage in the Elm Web API 
> - you're just swapping out Tasks for other Tasks. As the Web API will 
> always be changing, I think that having a nice way to make JS polyfills 
> like this will always have some value, let alone for interacting with 
> libraries written in JS that haven't or won't ever be ported to Elm.
>
> Elm would continue to make the same guarantees as with other ports; if the 
> task port can't marshall the response back into Elm an error would be 
> thrown along the same lines as is currently done via ports.
>
> Summary
>
> - regular ports only let you send data off or receive data back, not both.
> - Cmd's and Sub's are not composable
> - Task based ports allow you to create a new Task that is backed by JS
> - Task based ports allow for better composition and less friction when the 
> backing JS is eventually implemented in Elm.
>
> I'd love to hear what people think about this. Perhaps I'm missing some 
> big issues with the idea for instance, or maybe it's an awesome idea :) 
> What do you all 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.


[elm-discuss] Unrelated modules having ports with the same name

2016-08-22 Thread b123400
Hello, I find it confusing about ports in modules, I have sent an issue 
 but didn't get 
notice for a month, so I'd like to post it here for discussion.

I have two modules, they both have a port with the same name:

port module ModuleA exposing (main)
import Html exposing (text)import Platform.Sub as Sub
port incomePort : (String -> msg) -> Sub msg
main =
  text "Hello"

port module ModuleB exposing (main)
import Html exposing (text)import Platform.Sub as Sub
port incomePort : (String -> msg) -> Sub msg
main =
  text "Hey!"

And I compiled it by this command:

elm make ModuleA.elm ModuleB.elm --output combined.js

The generated JS file will output the following error:

Error: There can only be one port named `incomePort`, but your program has 
multiple.

These two modules are not connected and there should be no ambiguity 
between the ports. I think the ports name checking should be bounded to the 
module, instead of JS-file-wise.

By the way, when I generate the modules separately and include them in the 
same page, there is no error.

elm make ModuleA.elm --output a.js
elm make ModuleB.elm --output b.js




Is this behaviour intended?

-- 
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: So how do *you* handle Dates through ports?

2016-08-22 Thread OvermindDL1
On Monday, August 22, 2016 at 10:44:24 AM UTC-6, Kasey Speakman wrote:
>
> Re encoding: You can pass the value over as Json.Value and decode it, no?
>

Still involves an extra step regardless, and I like being explicit about 
types so I have my record.  It is a standard Javascript Date time object 
though, the style that is entirely explicit so there is no question about 
any aspect of the time, calendar, or anything of the sort, it is the almost 
accurate date object (to be more accurate you also need to define relative 
start/end locations and such, which involves relativity, which can be 
ignored in 'most' cases).

-- 
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: Possible compiler bug?

2016-08-22 Thread Max Goldstein
Ah, yup that looks fine. I had thought about adding some functions like this to 
Pcg but never got around to it. One of these days...

-- 
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: So how do *you* handle Dates through ports?

2016-08-22 Thread Kasey Speakman
The only ones that really makes sense to auto convert through a port is ISO 
string or JS native. If you use a strange object, then yeah you would need 
manual conversion.

Re encoding: You can pass the value over as Json.Value and decode it, no?

On Monday, August 22, 2016 at 11:25:31 AM UTC-5, OvermindDL1 wrote:
>
> Too many formats for date though.  ;-)
>
> Such as is it in a format of a String?  With or without timezone?  Is it 
> in the format of a record like this that I use:
> ```elm
> type alias JsonDateTime =
> { year : Int
> , timezone :
> { until : String
> , offset_utc : Int
> , offset_std : Int
> , full_name : String
> , from : String
> , abbreviation : String
> }
> , second : Int
> , month : Int
> , minute : Int
> , millisecond : Int
> , hour : Int
> , day : Int
> , calendar : String
> }
> ```
> The above record is parsed by the Javascript Date object without issue, 
> but nothing in Elm takes it so I have some nasty converting.  But there are 
> lots of ways and things.  Customized Encoding/Decoding for ports would be 
> awesome though.
>
>
> On Monday, August 22, 2016 at 9:55:39 AM UTC-6, Kasey Speakman wrote:
>>
>> Well, I'd wish for Dates to just automatically come over first. :)
>>
>> On Monday, August 22, 2016 at 10:50:39 AM UTC-5, OvermindDL1 wrote:
>>>
>>> I use the method of two records, one that comes in the port and one 
>>> after massaging it into the better format at the subscription step.  It is 
>>> ugly but I do not really see a way around it without being able to somehow 
>>> define our own Encoders/Decoders for ports (which I wish!).
>>>
>>>
>>> On Monday, August 22, 2016 at 9:22:06 AM UTC-6, Kasey Speakman wrote:

 If I have a record with a Date field, and I need to receive that 
 through a port (which I understand is not possible). Do I have to de/code 
 the whole record just because of this or is there a better way?

 Another way that occurs to me is to create two records, one with the 
 date as a string for going through the port. Then once it gets inside Elm, 
 use Date.fromString and map to the actual record type. Seems only slightly 
 better than de/coding.

 Thoughts?

>>>

-- 
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: So how do *you* handle Dates through ports?

2016-08-22 Thread OvermindDL1
Too many formats for date though.  ;-)

Such as is it in a format of a String?  With or without timezone?  Is it in 
the format of a record like this that I use:
```elm
type alias JsonDateTime =
{ year : Int
, timezone :
{ until : String
, offset_utc : Int
, offset_std : Int
, full_name : String
, from : String
, abbreviation : String
}
, second : Int
, month : Int
, minute : Int
, millisecond : Int
, hour : Int
, day : Int
, calendar : String
}
```
The above record is parsed by the Javascript Date object without issue, but 
nothing in Elm takes it so I have some nasty converting.  But there are 
lots of ways and things.  Customized Encoding/Decoding for ports would be 
awesome though.


On Monday, August 22, 2016 at 9:55:39 AM UTC-6, Kasey Speakman wrote:
>
> Well, I'd wish for Dates to just automatically come over first. :)
>
> On Monday, August 22, 2016 at 10:50:39 AM UTC-5, OvermindDL1 wrote:
>>
>> I use the method of two records, one that comes in the port and one after 
>> massaging it into the better format at the subscription step.  It is ugly 
>> but I do not really see a way around it without being able to somehow 
>> define our own Encoders/Decoders for ports (which I wish!).
>>
>>
>> On Monday, August 22, 2016 at 9:22:06 AM UTC-6, Kasey Speakman wrote:
>>>
>>> If I have a record with a Date field, and I need to receive that through 
>>> a port (which I understand is not possible). Do I have to de/code the whole 
>>> record just because of this or is there a better way?
>>>
>>> Another way that occurs to me is to create two records, one with the 
>>> date as a string for going through the port. Then once it gets inside Elm, 
>>> use Date.fromString and map to the actual record type. Seems only slightly 
>>> better than de/coding.
>>>
>>> Thoughts?
>>>
>>

-- 
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: Making imports more pleasant

2016-08-22 Thread Francesco Orsenigo
Are you going to write such plugin for every possible editor?
Is every newbie going to have such plugin?
What about browsing code from GitHub?

A language's readability should not depend on tooling.

On Mon, Aug 22, 2016 at 5:52 PM, William Bailey  wrote:
> For years I coded in Java using IntelliJ.  It was super easy in that IDE to
> hover on any symbol, system or otherwise, and learn all about it.  Or hit
> ctrl-B (eg) to drill into the source. Again, worked fine for system
> libraries and was really useful for seeing how the under-the-covers stuff
> worked.
>
> When I started coding in go-lang a couple years ago, people were griping
> about having to manually remove unused imports as the compiler would not
> allow that.  But now, most editors have plug-ins that do that automatically.
>
> So... I think focusing on what the core language should and should not allow
> here is misguided.  Just need better IDE tools.
>
> --
> 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/ydhKsvJtDZw/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: So how do *you* handle Dates through ports?

2016-08-22 Thread Kasey Speakman
Well, I'd wish for Dates to just automatically come over first. :)

On Monday, August 22, 2016 at 10:50:39 AM UTC-5, OvermindDL1 wrote:
>
> I use the method of two records, one that comes in the port and one after 
> massaging it into the better format at the subscription step.  It is ugly 
> but I do not really see a way around it without being able to somehow 
> define our own Encoders/Decoders for ports (which I wish!).
>
>
> On Monday, August 22, 2016 at 9:22:06 AM UTC-6, Kasey Speakman wrote:
>>
>> If I have a record with a Date field, and I need to receive that through 
>> a port (which I understand is not possible). Do I have to de/code the whole 
>> record just because of this or is there a better way?
>>
>> Another way that occurs to me is to create two records, one with the date 
>> as a string for going through the port. Then once it gets inside Elm, use 
>> Date.fromString and map to the actual record type. Seems only slightly 
>> better than de/coding.
>>
>> Thoughts?
>>
>

-- 
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: Making imports more pleasant

2016-08-22 Thread William Bailey
For years I coded in Java using IntelliJ.  It was super easy in that IDE to 
hover on any symbol, system or otherwise, and learn all about it.  Or hit 
ctrl-B (eg) to drill into the source. Again, worked fine for system 
libraries and was really useful for seeing how the under-the-covers stuff 
worked.

When I started coding in go-lang a couple years ago, people were griping 
about having to manually remove unused imports as the compiler would not 
allow that.  But now, most editors have plug-ins that do that automatically.

So... I think focusing on what the core language should and should not 
allow here is misguided.  Just need better IDE tools.

-- 
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] So how do *you* handle Dates through ports?

2016-08-22 Thread Kasey Speakman
If I have a record with a Date field, and I need to receive that through a 
port (which I understand is not possible). Do I have to de/code the whole 
record just because of this or is there a better way?

Another way that occurs to me is to create two records, one with the date 
as a string for going through the port. Then once it gets inside Elm, use 
Date.fromString and map to the actual record type. Seems only slightly 
better than de/coding.

Thoughts?

-- 
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: Making imports more pleasant

2016-08-22 Thread Francesco Orsenigo
Not at all.
You'd use qualified imports.

`import Html exposing (div, span, text, input, form)`

or

`import Html as H`
and then `H.div` `H.text` and so on.

One of the strength of Elm is keeping everything very explicit, which
makes it super newbie friendly.



On Mon, Aug 22, 2016 at 3:08 PM, Will White  wrote:
> I don't think it should be disallowed entirely. Disallowing it would make
> Html and other familiar things like that harder to read, without helping
> understanding.
>
> On Monday, August 22, 2016 at 11:10:38 AM UTC+1, Francesco Orsenigo wrote:
>>
>> The only issue I have with imports is that any code that contains several
>> unqualified imports is a pain in the ass to learn.
>>
>> Example:
>> https://github.com/Bogdanp/elm-combine/blob/2.2.1/examples/Python.elm
>>
>> As a newbie, it's immensely frustrating being unable to easily track which
>> of the `import Whatever exposing (..)` is actually providing a specific
>> symbol.
>> It should be disallowed entirely.
>> I don't mind writing more if it makes my code more readable.
>
> --
> 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/ydhKsvJtDZw/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.


Re: [elm-discuss] Re: Making imports more pleasant

2016-08-22 Thread Will White
I don't think it should be disallowed entirely. Disallowing it would make 
Html and other familiar things like that harder to read, without helping 
understanding.

On Monday, August 22, 2016 at 11:10:38 AM UTC+1, Francesco Orsenigo wrote:
>
> The only issue I have with imports is that any code that contains several 
> unqualified imports is a pain in the ass to learn.
>
> Example: 
> https://github.com/Bogdanp/elm-combine/blob/2.2.1/examples/Python.elm
>
> As a newbie, it's immensely frustrating being unable to easily track which 
> of the `import Whatever exposing (..)` is actually providing a specific 
> symbol.
> It should be disallowed entirely.
> I don't mind writing more if it makes my code more readable.
>

-- 
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] Dynamic implementation resolving

2016-08-22 Thread Larry Weya
I have a project where I would like to have different implementations 
depending on a provided value.

I have what we are referring to as Commands and we are using elm provide a 
UI used to configure a command's parameters so e.g. we have 2 Commands, a 
CreateInvoice command and a SendText command. They are persisted in a 
database as JSON. To edit the command, I load up the JSON and depending on 
the command's name I'd like my Main module to use the commands 
init/view/update functions. The biggest issue is that CreateInvoice and 
SendText models have different types.

Main.elm

-- how do I define a model that can accomodate both types

main = 
 Html.programWithFlags{...}

init : String -> Json.Encode.Value -> Model
init (moduleName, params) =
 -- how to init a command based on the moduleName


CreateInvoice.elm

type alias Model = {amount : Int}

init jsonValue =
 -- decode json value into model

SendText.elm

type alias Model = {message : String}

init jsonValue =
 -- decode json value into 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.


Re: [elm-discuss] Re: Making imports more pleasant

2016-08-22 Thread Francesco Orsenigo
The only issue I have with imports is that any code that contains several 
unqualified imports is a pain in the ass to learn.

Example: https://github.com/Bogdanp/elm-combine/blob/2.2.1/examples/Python.elm

As a newbie, it's immensely frustrating being unable to easily track which 
of the `import Whatever exposing (..)` is actually providing a specific 
symbol.
It should be disallowed entirely.
I don't mind writing more if it makes my code more readable.

-- 
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: Possible compiler bug?

2016-08-22 Thread Martin Janiczek
Sure, I just copied the function definition to my module that uses 
Random.Pcg instead of Random.
There was no need to change the implementation, it just uses 
Random.Pcg.constant instead of Random.Extra.constant, I believe.

import Random.Pcg as Random exposing (Generator)

{-| Turn a list of generators into a generator of lists.

This is a version working with Random.Pcg.
-}
together : List (Generator a) -> Generator (List a)
together generators =
case generators of
[] ->
Random.constant []

g :: gs ->
Random.map2 (::) g (together gs)



On Friday, August 19, 2016 at 4:24:07 PM UTC+2, Max Goldstein wrote:
>
> > I have created my own Random.Pcg `together` and it compiles.
>
> Would you mind clarifying what you mean by 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.


[elm-discuss] Hide component on document click

2016-08-22 Thread Francisco Ramos
Hi there,

I'm fairly new with Elm. I'm currently working on a personal project 
(Minesweeper, repo here: https://github.com/jscriptcoder/minesweeper-elm) 
to learn this fascinating language and architecture. I have this menu that 
opens when you click on a link. What I'd like to do is to hide it when you 
click away. Not sure what's the best way to do it. I thought about creating 
a port that will send a message to Elm on document click. But I'm 
wondering: it'll also send this message when I click on the link to open 
the menu. Then I'll have to stopPropagation when clicking on this link. Not 
sure how to do all this.

Any help, suggestion or link to an example would be highly appreciated.

Thanks a lot

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.