Re: [elm-discuss] Re: [Feature] Ability to suppress some warnings (or don't generate them at all)

2017-08-10 Thread joseph ni
Elm's warnings seems to be fairly restricted to missing annotations or
unused imports, both of which is arguably trivial and doesn't affect the
program's maintainability in any meaningful way imo as the previous
commenter said.

Don't get me wrong about whitespaces, I love what elm-format does. It took
me a greater perspective to see it, but now I love the fact that I don't
care about what it does. Spaces, indentation, comments, ordering, enough
ppl have put their collective brain power into it, just check out the
issues list.

As for me, I'm just glad I don't have to sit through a 2hr meeting with a
10 member team on whether a anonymous function in js should have a space
before the bracket or whether commas should be on the end or begin the next
line or the use of semi-colons. Instead, I hit save, it formats and I can
get on with it.


On 11 August 2017 at 11:36, Incomplete <incompl...@aixon.co> wrote:

> Seems to be good approach, I'll use it for colors, since it's the major
> pain; for others I'll just annotate them, (prefer zero-warning codes
> whenever possible).
>
> (Feel the same with white spaces, just changed from
> four-spaces-indentation to two spaces).
>
>
> On Friday, 11 August 2017 07:06:13 UTC+8, joseph ni wrote:
>>
>> For your CSS issue, you could put it in one function that took in a
>> EveryDict and a typed color then give back the hex.
>> I'd prefer to keep colors together rather than split them out in 2 line
>> functions with 2 spaces in between. Man elm-format goes to town with
>> whitespaces, such generosity.
>>
>> On Thursday, 10 August 2017 20:48:37 UTC+10, Jakub Hampl wrote:
>>>
>>> Warnings are really recommendations - if you choose to ignore them
>>> you'll be fine. In elm, dangerous things are errors, not warnings. So I
>>> suggest if you don't like the suggestions, simply stop using the --warn
>>> flag.
>>>
>>> On Wednesday, 9 August 2017 03:44:11 UTC+1, Incomplete wrote:
>>>>
>>>> Whenever I `elm-make`, I give it the `--warn` option, however, this
>>>> often makes the compiler generate warnings like "Top-level value `foo` does
>>>> not have a type annotation.", if there are a lot of these, it would make
>>>> the real warnings hard to notice.
>>>>
>>>> Sometimes I deliberately omit type annotations for top level values,
>>>> the reason is that these values are just some strings and numbers, (like
>>>> CSS colors, some constants, etc.), or even initial model of type
>>>> Model, there is really no need to annotate them, and annotating them would
>>>> make the code looks uglier (because in the case of CSS colors, you often
>>>> have several colors in succession, like `white=Css.hex "aabbcc" \n
>>>> black=Css.hex "bbccdd" \n green=Css.hex "ccddee", if you annotate them, it
>>>> becomes verbose).
>>>>
>>>> As someone pointed out, a good consequence of type inference is that
>>>> you don't have to write type declarations if you don't want to, however, I
>>>> think Elm may have a different opinion on this.
>>>>
>>> --
> 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/n5TNa_PlRSg/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: [Feature] Ability to suppress some warnings (or don't generate them at all)

2017-08-10 Thread joseph ni
For your CSS issue, you could put it in one function that took in a 
EveryDict and a typed color then give back the hex.
I'd prefer to keep colors together rather than split them out in 2 line 
functions with 2 spaces in between. Man elm-format goes to town with 
whitespaces, such generosity.

On Thursday, 10 August 2017 20:48:37 UTC+10, Jakub Hampl wrote:
>
> Warnings are really recommendations - if you choose to ignore them you'll 
> be fine. In elm, dangerous things are errors, not warnings. So I suggest if 
> you don't like the suggestions, simply stop using the --warn flag.
>
> On Wednesday, 9 August 2017 03:44:11 UTC+1, Incomplete wrote:
>>
>> Whenever I `elm-make`, I give it the `--warn` option, however, this often 
>> makes the compiler generate warnings like "Top-level value `foo` does not 
>> have a type annotation.", if there are a lot of these, it would make the 
>> real warnings hard to notice.
>>
>> Sometimes I deliberately omit type annotations for top level values, the 
>> reason is that these values are just some strings and numbers, (like CSS 
>> colors, some constants, etc.), or even initial model of type Model, there 
>> is really no need to annotate them, and annotating them would make the code 
>> looks uglier (because in the case of CSS colors, you often have several 
>> colors in succession, like `white=Css.hex "aabbcc" \n black=Css.hex 
>> "bbccdd" \n green=Css.hex "ccddee", if you annotate them, it becomes 
>> verbose).
>>
>> As someone pointed out, a good consequence of type inference is that you 
>> don't have to write type declarations if you don't want to, however, I 
>> think Elm may have a different opinion on 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] Re: My Argument for "Why Elm" please review before I present to my company

2017-01-12 Thread joseph ni
Reading through your points, it seems that this is not a pitch but rather a 
list of highly emotional responses to their concerns the first time around.

Alot of your statements are unqualified and comes across to me as being 
weakly backed up or unnecessary personal beliefs: 
"Elm adds far more value than redux such as a type system"
"Elm has been around for about 5 years which is far more stable than the JS 
libraries you would use to replace it"
"People want to work in Elm and would probably would attract more rather 
than less."
"breaking changes to the language they have been pretty minimal and have 
always been large improvements"
"It has basically no cruft."
"I feel the pros far outweigh the cons"
"you'll have less leaving because the front end makes them happy than sob 
into their pillow."   <--- is there something else going on here?

I personally wouldn't go ahead with your second pitch and would strongly 
suggest thinking along the lines of what Charlie said about creating a 
demo/prototype to show these strong points rather than repeating them in 
words.
In fact, that's what I'm doing right now with a work project and with a 
hobby project ( https://github.com/mordrax/cotwelm ). It's to both showcase 
Elm and my skills as a hireable Elm developer. :)


On Thursday, 12 January 2017 04:56:16 UTC+11, Gage Peterson wrote:
>
> I've been wanting to pitch (again) Elm as an alternative to Angular / 
> React + Redux. These are my arguments, please leave some comments:
>
>
> https://gist.github.com/justgage/7de5a2f9e639aec9436aad882fc90446 
>

-- 
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 logo license.)I want to make Elm logo stickers and distribute them

2016-12-20 Thread joseph ni
I would love to have one for my laptop and distribute these at the Sydney 
Elm meetup that's been going on for the last yr.

On Monday, 19 December 2016 10:55:14 UTC+11, hsw wrote:
>
>
> Hello, 
> I have a question about the Elm logo license.
> I want to print logo as a sticker and distribute it . Does this violate 
> the license?
>
> ・I will explain that it is Elm's logo.
> ・Free.
> ・It is the following two logos.
>
>
> 
>
>
> 
>
>

-- 
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 motivation for using google groups?

2016-11-28 Thread joseph ni
I used to follow MeteorJS and one of the main reasons for their switch from 
google groups to discourse was the spam google groups attracted once they 
got to some level of popularity.

So it might be out of necessity that we move... eventually.

On Monday, 28 November 2016 19:31:07 UTC+11, Håkon Rossebø wrote:
>
> I really like the Discourse forum and think it works very good on 
> https://elixirforum.com
>
>

-- 
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] Rename Just to Something, as the counterpart to Nothing?

2016-11-21 Thread joseph ni
I came to Elm not knowing about the Maybe type. 
The hardest thing for me to grasp was the use case and being able to map : 
(a -> b) -> Maybe a -> Maybe b. And knowing when to use a Maybe (rarely) vs 
when to use a union type or refactor the code so it doesn't need the Maybe 
type.

If I was to qualitatively estimate the amount of time spent learning about 
Maybe. I'd say it took me a moment to understand `Maybe a = Just a | 
Nothing` and a couple of months to get comfortable enough with the Maybe 
type now to understand where it's needed in my app.

So I'd tend to lean with Joey, the wording works for me and changing it 
would feel arbitrary and break the current grammatical 'symmetry' as in
weapon = Just sword 
vs 
weapon = Something sword

On Tuesday, 22 November 2016 08:19:21 UTC+11, Oliver Searle-Barnes wrote:
>
> I have to admit I did find `Just` very confusing when I first encountered 
> it, as mentioned earlier in this thread it implies some kind of limitation 
> which doesn't match the semantics of Maybe at all. That said, it was one of 
> those little oddities that very quickly become second nature, just wanted 
> to point out that it is a slight bump in the road for newcomers.
>
>
> On Monday, 21 November 2016 18:34:05 UTC+1, Noah Hall wrote:
>>
>> Has anyone actually encountered anyone being confused by the names? I 
>> haven't. I think this a solution to a problem that doesn't exist. 
>>
>> On Mon, Nov 21, 2016 at 6:15 PM, Will White  wrote: 
>> > I think that’s because you already know what Just means. I don’t think 
>> it’s 
>> > arbitrary though from an accessibility point of view. Some or None is 
>> easier 
>> > for newcomers to understand than Just or Nothing, especially as Some 
>> isn’t 
>> > misleading the way Just is, as Andrew described well. 
>> > 
>> > On 21 Nov 2016, at 17:05, Joey Eremondi  wrote: 
>> > 
>> > Honestly, these choices seem pretty arbitrary. Everyone has a 
>> preference. ML 
>> > uses Some/None, Haskell uses Just/Nothing. Some people find Something 
>> > intuitive, some don't. 
>> > 
>> > Given that the choices is (mostly) arbitrary, it seems best to stick 
>> with 
>> > the status quo. 
>> > 
>> > On Mon, Nov 21, 2016 at 7:47 AM, 'Andrew Radford' via Elm Discuss 
>> >  wrote: 
>> >> 
>> >> Probably inherited from Haskell, like a lot of other stuff. Doubt if 
>> there 
>> >> was any other thought put into it if I'm honest. 
>> >> 
>> >> On Monday, 21 November 2016 14:46:40 UTC, Will White wrote: 
>> >>> 
>> >>> Sorry, meant to say “I guess he’s already considered and rejected 
>> them”. 
>> >>> 
>> >>> On 21 Nov 2016, at 14:21, Will White  wrote: 
>> >>> 
>> >>> I prefer Some or None, for understanding. Though, unless Evan didn’t 
>> know 
>> >>> about them, I guess we’d already have them. 
>> >>> 
>> >>> On 20 Nov 2016, at 23:41, Robin Heggelund Hansen  
>>
>> >>> wrote: 
>> >>> 
>> >>> How about 'Some' and 'None'? 
>> >>> Those are not longer to type than what we have today, and they should 
>> >>> solve your initial confusion. 
>> >>> 
>> >>> søndag 20. november 2016 18.16.26 UTC+1 skrev Will White følgende: 
>>  
>>  I'm talking about Maybe.Just, of course. Just has always seemed 
>> strange 
>>  to me, as if it's hinting that it's something other than just the 
>>  counterpart to Nothing. I don't know the reasons behind its naming, 
>> but I 
>>  think I would prefer Something, as in "something or nothing". What 
>> do you 
>>  think? 
>> >>> 
>> >>> 
>> >>> -- 
>> >>> 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/EHnuE_gGFuo/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...@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/EHnuE_gGFuo/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 

Re: [elm-discuss] Re: Why Range syntax got removed in favor of List.range

2016-11-13 Thread joseph ni
The _real_ question is why List.Range only increments, List.Range 5 1 = [ ]

On Monday, 14 November 2016 09:32:12 UTC+11, Francesco Orsenigo wrote:
>
> What do you mean with "suits best"? 
> Readability is largely a matter of familiarity. 
>
> On Mon, Nov 14, 2016 at 9:21 AM, 'Andrew Radford' via Elm Discuss 
>  wrote: 
> > Simply cause then I can use whichever one suits best, makes the code 
> more 
> > readable etc 
> > 
> > 
> > On Sunday, 13 November 2016 21:47:17 UTC, Francesco Orsenigo wrote: 
> >> 
> >> 
> >> Why would you want two different (and entirely equivalent) solutions to 
> >> the same problem? 
> >> 
> >> 
> >> On Monday, November 14, 2016 at 8:37:34 AM UTC+11, Andrew Radford 
> wrote: 
> >>> 
> >>> Yeah It would be great if there was [x..y] and Range 
> > 
> > 
> > -- 
> > 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/z8t8u2f3iWk/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: Proposal: Rename case..of -> match..with

2016-10-23 Thread joseph ni
> The reason being that I believe the words better matches what the 
construct does.

To me, `case x of` conveys *what* the construct does. It says, handle all 
the different cases/scenarios/possibilities of `x` as follows. Ties in 
nicely with the compiler msg: "You haven't handled these cases of this 
type".

`match x with` conveys *how* it does it. I'm going to match `x` with some 
destructured patterns below but it says nothing about what those patterns 
are so we are losing the intention of the construct imo.

In some crude sense, it would be like renaming `List.map` to 
`List.turnAintoB`. The former is more about intention, the latter about 
implementation.


On Friday, 21 October 2016 01:06:53 UTC+11, Robin Heggelund Hansen wrote:
>
> First of, I would like to say that for me personally, this proposal 
> doesn't matter.
> This proposal is written because I believe people with little to no Elm 
> experience will understand the construct better.
>
> The proposal, as the title of the post suggests, is to rename the 
> "case..of" expression to "match..with". The reason being that I believe the 
> words better matches what the construct does. As a non-native English 
> speaker, case..of doesn't immediately make sense. However, match..with 
> makes perfect sense.
>
> Match..with is what the same construct is called in F#, so it has that 
> going for it.
>
> Case..of to match..with renaming could be handled by elm-format.
>
> As said, to me personally and, I believe, other seasoned elm devs, this 
> won't matter that much.
> The question therefore becomes, how big of a difference will it make to 
> new and future elm developers?
>

-- 
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: Post mortem for my first attempt at using Elm in a real app.

2016-09-20 Thread joseph ni
> - *Elm is an amazing language.* I've had countless moments of sheer 
pleasure programming in Elm for this app. 

Actually, this is *my* take away from the very nicely written, down to 
earth post-mortem. I've been hammering away at web-frameworks for 4 yrs 
(angular, blaze, react) and windows webforms before that. In all those 
frameworks, I have found things that don't fit, workarounds that are hacky, 
abstractions which leak, complex tooling etc etc... in not one of them have 
I said wow... it's been smooth sailing all the way through. Elm is the same 
in that sense. It's story is not complete.

However, in none of those frameworks/languages have I had the consistency 
of highs and pleasure working in a immutable, pure functional environment 
that allows me to express what I want concisely with the confidence that it 
will work as intended. 

Granted I'm not using Elm for a web app, rather a game in Elm, ~6k LoC 
hardly any regression bugs, everything in Elm, it's getting complex, but 
I'm madly refactoring as I go, fearlessly because the compiler's got my 
back. The workflow is great as I'm able to solve problems and move on. I'm 
optimistic about where we're heading :) Don't stop!
 

On Wednesday, 21 September 2016 07:37:30 UTC+10, Brian Marick wrote:
>
>
> On Sep 20, 2016, at 3:46 PM, Peter Damoc  
> wrote:
>
> As Richard pointed out, Elm is a great choice when the team is already 
> comfortable with web-dev. 
> I am a beginner in this field. 
>
>
> I’m a front-end beginner too. I wonder how many of us there are, and how 
> we might help one another.
>

-- 
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: Any tricks for debugging?

2016-09-15 Thread joseph ni
Ahh, I needs it! Just spent last night trawling through chrome dev console 
looking at single line formatted debug.log, finally found the bug after an 
hour but it took me back to js days...

Because all your business logic is explicitly reflected in your model, 
being able to step and look at your model would cover pretty much *all* 
logic bugs! Frothing at the thought of time traveller coming back in 0.18. 
I've had very limited success with jinjor's debugger, even though it was 
some amazing work, it was too slow for my game state to debug properly.

On Friday, 16 September 2016 05:55:39 UTC+10, Zinggi wrote:
>
> Well elm-conf  is happening right now, so we'll 
> get more info very soon.
>
> On Thursday, 15 September 2016 21:50:42 UTC+2, John Orford wrote:
>>
>> any ballpark guesses on when 0.18 will happen? before the end of the year 
>> perhaps?
>>
>> On Thu, 15 Sep 2016 at 21:37 Zinggi  wrote:
>>
>>> You could wait some time on the 0.18 release which will most likely 
>>> bring back the time traveling debugger, with object introspection.
>>> This is much more comfortable than Debug.log.
>>>
>>> For now, you could use this library 
>>>  which 
>>> also works quite nicely. (except if you have many messages per second, e.g. 
>>> for game/animation things)
>>>
>>> Debug.log covers all the the other cases. However, if I wanted to print 
>>> all messages, I'd do it like this:
>>>
>>> update msg model =
>>> case Debug.log "Msg" msg of
>>> Foo -> ...
>>>
>>>
>>> On Thursday, 15 September 2016 12:24:46 UTC+2, Rupert Smith wrote:

 I am finding it useful to know which Msgs are being triggered through 
 my update functions, so have been putting in code like this:

 log =
 Debug.log "myModule"

 ...

 Add ->
 let d = log "add" in
...

 Now I have decided it would be easier to just print all Msgs rather 
 than add this to specific ones:

 debug : a -> a
 debug a =
 Debug.log "myModule" a


 update : Msg -> Model -> ( Model, Cmd Msg )
 update action model =
 update' (debug action) model
 -- OR even update' (debug action) (debug model)

 update' : Msg -> Model -> ( Model, Cmd Msg )

 And am considering pulling up the 'debug' function into its own module, 
 so I can easily globally turn on/off debug tracing by switching it between 
 the identity function or the logging function.

 Just wondering if anyone has any helpfull debugging tricks they like to 
 use with 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...@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] Moderating elm-discuss

2016-09-07 Thread joseph ni
Discourse is what the meteorjs community went to after losing the spam war on 
google groups. https://forums.meteor.com 

After the move, we've had very few issues with spam. It's got a nice interface 
and comes with a good set of features you'd expect from a forum site.

-- 
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: Confusing behavior with Random module

2016-08-27 Thread joseph ni
In your Random.map2 you're calling rMines and adding that to your model.

Then you call rTargets, which calls rTargetPoss which calls rMines *again*, 
this is a independent rMines which gives you another set of results. You 
use this second rMines to generate the second set of (x, y) which explains 
why it can repeat your answers.

This is exactly the problem that I was having with my generators. What I 
ended up doing was having signatures that look like this
```
rTargetPos : Model -> Generator Model

rMine : Model -> Generator Model

```

and do something like

```
constant init 
`andThen` rMine 
`andThen` rTargetPos
```

This way, you're updating the model and passing that from rMine to 
rTargetPos.

Here is an example of how I'm doing my generator 
chaining: 
https://github.com/mordrax/cotwelm/blob/master/src/Dungeon/Room.elm#L45

Cheers,
Joe

On Sunday, 28 August 2016 13:16:18 UTC+10, Nate Clark wrote:
>
> I think I'm seeing some unusual behavior while generating a random value. 
> I'm trying to sample multiple (x,y) pairs from a set of available (x,y), 
> and then sample again from the remaining pairs. The final set (which 
> shouldn't contain any items from the first set), seemed to contain items 
> from the first set. So, I added some Debug.log calls in hope of getting a 
> peek into the random values as they are being generated, and I noticed that 
> one of the log calls was occurring twice. I've included the log calls and 
> the console output below.
>
>
> randomGame : Int -> Random.Generator Model
> randomGame level =
> let numTargets = 5 + level
> numMines = (25 - numTargets) // 2
> rMines = 
> allPoss
> |> randomPoss numMines 
> |> Random.map (log "mines")
> 
> rTargetPoss =
> rMines 
> |> Random.map (Set.diff allPoss) 
> |> Random.map (log "possible target positions")
> 
> rTargets = 
> rTargetPoss
> `Random.andThen` (randomTargets numTargets)
> |> Random.map (log "targets")
> in
> Random.map2 (\ms ts -> {mines=ms, targets=ts, exposed=Set.empty}) 
> rMines rTargets
> |> Random.map (log "model")
>
>
>
>
> 
>
>
> It logs "mines" twice. The first time seems to be the value that is kept 
> for the model, but the second "mines" is used to generate the possible 
> target positions.
>
> The full source code (< 350 lines) is at 
> https://github.com/natec425/Voltorb-Flip/blob/master/game.elm. Any help 
> would be greatly appreciated.
>

-- 
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] Drag example causes all other Html.Events to be ignored

2016-06-08 Thread joseph ni
I'm working off the elm-lang.org/examples/drag and trying to do a 
'mouseover' action whilst I've got the green box being dragged. However, 
the 'mouseover' does not fire while the box is being dragged.

I've reproduced this by making some minimal changes to the example code. If 
you copy/paste this over the example, everything should be the same except 
for this text at the top: Drag over me and it should crash!
The only difference is that this text has a 'mouseover' that fires off a 
'Crash' message which causes the update function to do a Debug.crash

If you move your mouse over it, it will cause elm to crash (in the console).
But if you drag the box over it, elm doesn't crash because it doesn't 
register the 'mouseover' message.

```
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (on)
import Json.Decode as Json exposing ((:=))
import Mouse exposing (Position)



main =
  Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}


-- MODEL


type alias Model =
{ position : Position
, drag : Maybe Drag
}


type alias Drag =
{ start : Position
, current : Position
}


init : ( Model, Cmd Msg )
init =
  ( Model (Position 200 200) Nothing, Cmd.none )



-- UPDATE


type Msg
= DragStart Position
| DragAt Position
| DragEnd Position
| Crash


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
  ( updateHelp msg model, Cmd.none )


updateHelp : Msg -> Model -> Model
updateHelp msg ({position, drag} as model) =
  case msg of
DragStart xy ->
  Model position (Just (Drag xy xy))

DragAt xy ->
  Model position (Maybe.map (\{start} -> Drag start xy) drag)

DragEnd _ ->
  Model (getPosition model) Nothing
  
Crash -> Debug.crash "Crashed!"



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
  case model.drag of
Nothing ->
  Sub.none

Just _ ->
  Sub.batch [ Mouse.moves DragAt, Mouse.ups DragEnd ]



-- VIEW


(=>) = (,)


view : Model -> Html Msg
view model =
  let
realPosition =
  getPosition model
  in
div [] [
div
  [ onMouseDown
  , style
  [ "background-color" => "#3C8D2F"
  , "cursor" => "move"

  , "width" => "100px"
  , "height" => "100px"
  , "border-radius" => "4px"
  , "position" => "absolute"
  , "left" => px realPosition.x
  , "top" => px realPosition.y

  , "color" => "white"
  , "display" => "flex"
  , "align-items" => "center"
  , "justify-content" => "center"
  ]
  ]
  [ text "Drag Me!"
  ],
  div [on "mouseover" (Json.succeed Crash)][ text "Drag over me and it 
should crash!" ]
]

px : Int -> String
px number =
  toString number ++ "px"


getPosition : Model -> Position
getPosition {position, drag} =
  case drag of
Nothing ->
  position

Just {start,current} ->
  Position
(position.x + current.x - start.x)
(position.y + current.y - start.y)


onMouseDown : Attribute Msg
onMouseDown =
  on "mousedown" (Json.map DragStart Mouse.position)
```

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