[elm-discuss] Re: Convert Char to Int?

2017-01-27 Thread John Watson
I think this issue is related to your problem 
- https://github.com/elm-lang/http/issues/11. *HTTP.getString *resolves to 
javascript *readAsText *whereas what you need is something that resolves to 
*readAsBinaryString*.  This got lost when elm-lang/http replaced 
evancz/elm-http.

On Friday, 27 January 2017 03:55:03 UTC, Duane Johnson wrote:
>
> Big picture:
>
> I'm writing a visual display algorithm of a binary ".hex" file that is the 
> result of compiling code on the Arduino platform. I load the file into the 
> browser via HTTP.getString, and then attempt to display the values.
>
> Problem:
>
> I'm unable to find a way to represent this binary data stream as a series 
> of 16-bit integers. I've attempted String.toList which results in a (List 
> Char) type, but what should I do with Char? Char.toCode and Char.fromCode 
> seem specifically tuned for use with keyboard events.
>
> Is there a way to handle a binary data series in Elm?
>
> Thanks,
> Duane Johnson
>

-- 
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: Intended usage of -- comments (and elm-format)

2017-01-07 Thread John Watson
I think this is a bug in elm-format 
- https://github.com/avh4/elm-format/issues/162

On Friday, 6 January 2017 22:14:12 UTC, Rupert Smith wrote:
>
> On Friday, January 6, 2017 at 6:29:43 PM UTC, Mark Hamburg wrote:
>>
>> What is the intended usage of -- comments in Elm? I'm used to using them 
>> as line end comments in other languages and/or lightweight comment lines 
>> all to themselves but elm-format tends to respond to them by more radically 
>> adjusting the code layout which suggests either that their intended usage 
>> in Elm is different than I am expecting or that elm-format needs some work 
>> in this regard.
>
>
> I notice that too. Commenting functional code well is harder than 
> imperative, because it is so terse and with function chaining there can 
> sometimes be nowhere to put a comment. I tried line end comments with -- 
> but elm-format moved them onto the next line and messed everything up. 
>

-- 
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: Race condition in textareas?

2016-12-09 Thread John Watson
In case anyone's still interested, I sorted out the problem I think. 
 defaultValue is working absolutely fine.  The problem appears to be that 
there is a difference between the way Firefox on the one hand and Chrome 
and Safari on the other require you to get input from the slider.  The 
former requires "on input" whilst the latter requires "on change" - 
see 
http://stackoverflow.com/questions/18544890/onchange-event-on-input-type-range-is-not-triggering-in-firefox-while-dragging.
 
Fixed simply by adding both.

On Wednesday, 7 December 2016 18:26:16 UTC, John Watson wrote:
>
> Many thanks - very useful.  I'm not entirely sure how best to achieve this 
> - I need to spend a bit of time investigating.
>
> On Wednesday, 7 December 2016 15:16:25 UTC, OvermindDL1 wrote:
>>
>> Elm does not use Shady DOM nor Shadow DOM, so that would be unrelated 
>> unless you are using the Shady or Shadow DOM's outside of elm but within 
>> the elm application.
>>
>> For note, updating the defaultValue will only update the textarea if the 
>> textarea is destroyed and recreated, updating the value will update it in 
>> real time but that means that you can also desync from a user typing if 
>> incoming messages overwrite each other if the user types too fast.  I 
>> tended to only set the 'value' when I wanted to force overwrite and just 
>> did not set it at all for the rest of the messages to work around it.
>>
>>
>> On Wednesday, December 7, 2016 at 2:50:59 AM UTC-7, John Watson wrote:
>>>
>>> My code seems to fail in Firefox immediately a slider is operated by the 
>>> user.  After reading this discussion 
>>> <https://groups.google.com/forum/#!topic/elm-dev/TvnVOpz3l0Q> on shady 
>>> dom, I'm wondering whether the issue is that Firefox has no 
>>> implementation <http://caniuse.com/#search=shadow%20DOM>of shadow dom 
>>> whilst both Chrome and Opera do.  Surely this is no coincidence - can 
>>> anyone enlighten me?
>>>
>>> On Monday, 5 December 2016 17:09:06 UTC, John Watson wrote:
>>>>
>>>> Maybe I spoke slightly too soon.  I have an application where the 
>>>> 'model' which is visible to the text area can also be modified by buttons 
>>>> and other input widgets.  After making the change in the text area from 
>>>> value to defaultValue, things continue to work as expected with Chrome and 
>>>> Opera, but no longer with Firefox.  What happens is that things go well 
>>>> for 
>>>> a bit, but after using the other input widgets, after a little while, the 
>>>> text area 'freezes' and no longer seems to accept updates from the model.
>>>>
>>>> On Monday, 5 December 2016 15:24:48 UTC, John Watson wrote:
>>>>>
>>>>> Thanks very much, Wil. I was suffering from this and this change fixes 
>>>>> it I think.
>>>>>
>>>>> On Monday, 5 December 2016 15:08:22 UTC, Wil C wrote:
>>>>>>
>>>>>> I just ran into this problem. And the work around was pretty simple, 
>>>>>> and mentioned in a message in this group a while back.
>>>>>>
>>>>>>   textarea [
>>>>>> property "defaultValue" (Json.Encode.string model.body)
>>>>>>   , onInput UpdateBody
>>>>>>   , rows (model.cursorAperture * 2)
>>>>>>   , id "edit-glass"
>>>>>>   , class "form-control"] []
>>>>>> ]
>>>>>>
>>>>>> I used defaultValue instead of value. I think the textarea and the 
>>>>>> various frameworks fight each other when 'value' is used, so you get the 
>>>>>> jumpiness going on. I think it's because Elm is keyed off of 'value' for 
>>>>>> updates. This way, the textarea maintains its own state, and when it 
>>>>>> changes, it doesn't trigger a re-render from Elm for the textarea itself.
>>>>>>
>>>>>> On Saturday, December 3, 2016 at 11:08:38 AM UTC-8, Esteban Manchado 
>>>>>> Velázquez wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have a strange, intermittent issue with textareas. It mostly seems 
>>>>>>> to happen in mobile browsers. The issue is that, when editing text *in 
>>>>>>> the 
>>>>>>> middle* of a textarea, as opposed to adding to the end, sometimes the 
>>>>>>> cursor jumps to the end. I assume it's some kind of re-creation of the 
>>>>>>> textarea DOM element.
>>>>>>>
>>>>>>> I have made a simple application with a textarea but that DOES seem 
>>>>>>> to work fine... so I'm wondering if the problem happens because my 
>>>>>>> application is bigger, and I have "subapplications" that use App.map 
>>>>>>> for 
>>>>>>> messages and so on.
>>>>>>>
>>>>>>> Has anyone seen that before? Is it something stupid I'm doing, a bug 
>>>>>>> in Elm, ...? I can make the full source code available if that'll help.
>>>>>>>
>>>>>>

-- 
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: Race condition in textareas?

2016-12-07 Thread John Watson
Many thanks - very useful.  I'm not entirely sure how best to achieve this 
- I need to spend a bit of time investigating.

On Wednesday, 7 December 2016 15:16:25 UTC, OvermindDL1 wrote:
>
> Elm does not use Shady DOM nor Shadow DOM, so that would be unrelated 
> unless you are using the Shady or Shadow DOM's outside of elm but within 
> the elm application.
>
> For note, updating the defaultValue will only update the textarea if the 
> textarea is destroyed and recreated, updating the value will update it in 
> real time but that means that you can also desync from a user typing if 
> incoming messages overwrite each other if the user types too fast.  I 
> tended to only set the 'value' when I wanted to force overwrite and just 
> did not set it at all for the rest of the messages to work around it.
>
>
> On Wednesday, December 7, 2016 at 2:50:59 AM UTC-7, John Watson wrote:
>>
>> My code seems to fail in Firefox immediately a slider is operated by the 
>> user.  After reading this discussion 
>> <https://groups.google.com/forum/#!topic/elm-dev/TvnVOpz3l0Q> on shady 
>> dom, I'm wondering whether the issue is that Firefox has no 
>> implementation <http://caniuse.com/#search=shadow%20DOM>of shadow dom 
>> whilst both Chrome and Opera do.  Surely this is no coincidence - can 
>> anyone enlighten me?
>>
>> On Monday, 5 December 2016 17:09:06 UTC, John Watson wrote:
>>>
>>> Maybe I spoke slightly too soon.  I have an application where the 
>>> 'model' which is visible to the text area can also be modified by buttons 
>>> and other input widgets.  After making the change in the text area from 
>>> value to defaultValue, things continue to work as expected with Chrome and 
>>> Opera, but no longer with Firefox.  What happens is that things go well for 
>>> a bit, but after using the other input widgets, after a little while, the 
>>> text area 'freezes' and no longer seems to accept updates from the model.
>>>
>>> On Monday, 5 December 2016 15:24:48 UTC, John Watson wrote:
>>>>
>>>> Thanks very much, Wil. I was suffering from this and this change fixes 
>>>> it I think.
>>>>
>>>> On Monday, 5 December 2016 15:08:22 UTC, Wil C wrote:
>>>>>
>>>>> I just ran into this problem. And the work around was pretty simple, 
>>>>> and mentioned in a message in this group a while back.
>>>>>
>>>>>   textarea [
>>>>> property "defaultValue" (Json.Encode.string model.body)
>>>>>   , onInput UpdateBody
>>>>>   , rows (model.cursorAperture * 2)
>>>>>   , id "edit-glass"
>>>>>   , class "form-control"] []
>>>>> ]
>>>>>
>>>>> I used defaultValue instead of value. I think the textarea and the 
>>>>> various frameworks fight each other when 'value' is used, so you get the 
>>>>> jumpiness going on. I think it's because Elm is keyed off of 'value' for 
>>>>> updates. This way, the textarea maintains its own state, and when it 
>>>>> changes, it doesn't trigger a re-render from Elm for the textarea itself.
>>>>>
>>>>> On Saturday, December 3, 2016 at 11:08:38 AM UTC-8, Esteban Manchado 
>>>>> Velázquez wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have a strange, intermittent issue with textareas. It mostly seems 
>>>>>> to happen in mobile browsers. The issue is that, when editing text *in 
>>>>>> the 
>>>>>> middle* of a textarea, as opposed to adding to the end, sometimes the 
>>>>>> cursor jumps to the end. I assume it's some kind of re-creation of the 
>>>>>> textarea DOM element.
>>>>>>
>>>>>> I have made a simple application with a textarea but that DOES seem 
>>>>>> to work fine... so I'm wondering if the problem happens because my 
>>>>>> application is bigger, and I have "subapplications" that use App.map for 
>>>>>> messages and so on.
>>>>>>
>>>>>> Has anyone seen that before? Is it something stupid I'm doing, a bug 
>>>>>> in Elm, ...? I can make the full source code available if that'll help.
>>>>>>
>>>>>

-- 
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: Race condition in textareas?

2016-12-07 Thread John Watson
My code seems to fail in Firefox immediately a slider is operated by the 
user.  After reading this discussion 
<https://groups.google.com/forum/#!topic/elm-dev/TvnVOpz3l0Q> on shady dom, 
I'm wondering whether the issue is that Firefox has no implementation 
<http://caniuse.com/#search=shadow%20DOM>of shadow dom whilst both Chrome 
and Opera do.  Surely this is no coincidence - can anyone enlighten me?

On Monday, 5 December 2016 17:09:06 UTC, John Watson wrote:
>
> Maybe I spoke slightly too soon.  I have an application where the 'model' 
> which is visible to the text area can also be modified by buttons and other 
> input widgets.  After making the change in the text area from value to 
> defaultValue, things continue to work as expected with Chrome and Opera, 
> but no longer with Firefox.  What happens is that things go well for a bit, 
> but after using the other input widgets, after a little while, the text 
> area 'freezes' and no longer seems to accept updates from the model.
>
> On Monday, 5 December 2016 15:24:48 UTC, John Watson wrote:
>>
>> Thanks very much, Wil. I was suffering from this and this change fixes it 
>> I think.
>>
>> On Monday, 5 December 2016 15:08:22 UTC, Wil C wrote:
>>>
>>> I just ran into this problem. And the work around was pretty simple, and 
>>> mentioned in a message in this group a while back.
>>>
>>>   textarea [
>>> property "defaultValue" (Json.Encode.string model.body)
>>>   , onInput UpdateBody
>>>   , rows (model.cursorAperture * 2)
>>>   , id "edit-glass"
>>>   , class "form-control"] []
>>> ]
>>>
>>> I used defaultValue instead of value. I think the textarea and the 
>>> various frameworks fight each other when 'value' is used, so you get the 
>>> jumpiness going on. I think it's because Elm is keyed off of 'value' for 
>>> updates. This way, the textarea maintains its own state, and when it 
>>> changes, it doesn't trigger a re-render from Elm for the textarea itself.
>>>
>>> On Saturday, December 3, 2016 at 11:08:38 AM UTC-8, Esteban Manchado 
>>> Velázquez wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a strange, intermittent issue with textareas. It mostly seems to 
>>>> happen in mobile browsers. The issue is that, when editing text *in the 
>>>> middle* of a textarea, as opposed to adding to the end, sometimes the 
>>>> cursor jumps to the end. I assume it's some kind of re-creation of the 
>>>> textarea DOM element.
>>>>
>>>> I have made a simple application with a textarea but that DOES seem to 
>>>> work fine... so I'm wondering if the problem happens because my 
>>>> application 
>>>> is bigger, and I have "subapplications" that use App.map for messages and 
>>>> so on.
>>>>
>>>> Has anyone seen that before? Is it something stupid I'm doing, a bug in 
>>>> Elm, ...? I can make the full source code available if that'll help.
>>>>
>>>

-- 
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: Race condition in textareas?

2016-12-05 Thread John Watson
Maybe I spoke slightly too soon.  I have an application where the 'model' 
which is visible to the text area can also be modified by buttons and other 
input widgets.  After making the change in the text area from value to 
defaultValue, things continue to work as expected with Chrome and Opera, 
but no longer with Firefox.  What happens is that things go well for a bit, 
but after using the other input widgets, after a little while, the text 
area 'freezes' and no longer seems to accept updates from the model.

On Monday, 5 December 2016 15:24:48 UTC, John Watson wrote:
>
> Thanks very much, Wil. I was suffering from this and this change fixes it 
> I think.
>
> On Monday, 5 December 2016 15:08:22 UTC, Wil C wrote:
>>
>> I just ran into this problem. And the work around was pretty simple, and 
>> mentioned in a message in this group a while back.
>>
>>   textarea [
>> property "defaultValue" (Json.Encode.string model.body)
>>   , onInput UpdateBody
>>   , rows (model.cursorAperture * 2)
>>   , id "edit-glass"
>>   , class "form-control"] []
>> ]
>>
>> I used defaultValue instead of value. I think the textarea and the 
>> various frameworks fight each other when 'value' is used, so you get the 
>> jumpiness going on. I think it's because Elm is keyed off of 'value' for 
>> updates. This way, the textarea maintains its own state, and when it 
>> changes, it doesn't trigger a re-render from Elm for the textarea itself.
>>
>> On Saturday, December 3, 2016 at 11:08:38 AM UTC-8, Esteban Manchado 
>> Velázquez wrote:
>>>
>>> Hi,
>>>
>>> I have a strange, intermittent issue with textareas. It mostly seems to 
>>> happen in mobile browsers. The issue is that, when editing text *in the 
>>> middle* of a textarea, as opposed to adding to the end, sometimes the 
>>> cursor jumps to the end. I assume it's some kind of re-creation of the 
>>> textarea DOM element.
>>>
>>> I have made a simple application with a textarea but that DOES seem to 
>>> work fine... so I'm wondering if the problem happens because my application 
>>> is bigger, and I have "subapplications" that use App.map for messages and 
>>> so on.
>>>
>>> Has anyone seen that before? Is it something stupid I'm doing, a bug in 
>>> Elm, ...? I can make the full source code available if that'll help.
>>>
>>

-- 
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: Race condition in textareas?

2016-12-05 Thread John Watson
Thanks very much, Wil. I was suffering from this and this change fixes it I 
think.

On Monday, 5 December 2016 15:08:22 UTC, Wil C wrote:
>
> I just ran into this problem. And the work around was pretty simple, and 
> mentioned in a message in this group a while back.
>
>   textarea [
> property "defaultValue" (Json.Encode.string model.body)
>   , onInput UpdateBody
>   , rows (model.cursorAperture * 2)
>   , id "edit-glass"
>   , class "form-control"] []
> ]
>
> I used defaultValue instead of value. I think the textarea and the various 
> frameworks fight each other when 'value' is used, so you get the jumpiness 
> going on. I think it's because Elm is keyed off of 'value' for updates. 
> This way, the textarea maintains its own state, and when it changes, it 
> doesn't trigger a re-render from Elm for the textarea itself.
>
> On Saturday, December 3, 2016 at 11:08:38 AM UTC-8, Esteban Manchado 
> Velázquez wrote:
>>
>> Hi,
>>
>> I have a strange, intermittent issue with textareas. It mostly seems to 
>> happen in mobile browsers. The issue is that, when editing text *in the 
>> middle* of a textarea, as opposed to adding to the end, sometimes the 
>> cursor jumps to the end. I assume it's some kind of re-creation of the 
>> textarea DOM element.
>>
>> I have made a simple application with a textarea but that DOES seem to 
>> work fine... so I'm wondering if the problem happens because my application 
>> is bigger, and I have "subapplications" that use App.map for messages and 
>> so on.
>>
>> Has anyone seen that before? Is it something stupid I'm doing, a bug in 
>> Elm, ...? I can make the full source code available if that'll help.
>>
>

-- 
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: Whither Rationals?

2016-11-26 Thread John Watson
Hi, Nick,

I'd be very interested to see that if you have managed to carry over all 
the infix operators from *Basics*.  I tried something like this myself in a 
fork of imeckler/ratio, but found that (for example) Basics.(+) would 
interfere with Ratio.(+).  In the end I used operators like (|+|), (+|) and 
(|+) for the cases where you're a) adding two rationals, (b) adding an int 
to a rational or (c) adding a rational to an int.  I found it relatively 
unobtrusive but I seem to get the feeling that this sort of thing is 
becoming frowned upon.  I have hesitated to publish it.

On Saturday, 26 November 2016 20:57:50 UTC, Nick H wrote:
>
> I have a module that implements most of the math functions from *Basics* 
> for rational numbers. Happy to publish it.
>
> For interop with ints, there is
>
> int : Int -> Rational
>
> Then converting back you have the normal round/floor/ceiling as well as 
> toFloat. Is that unobtrusive enough?
>
>
> On Sat, Nov 26, 2016 at 9:44 AM, John Watson <john@gmx.co.uk 
> > wrote:
>
>> Nothing too complex.  I do stuff with music notation, which has the 
>> concept of half note, quarter note etc.  One thing I've been toying with is 
>> porting the Haskell School of Music 
>> <http://haskell.cs.yale.edu/wp-content/uploads/2015/03/HSoM.pdf> / 
>> Euterpea <https://github.com/Euterpea/Euterpea> to Elm. I just prefer to 
>> model things with the right abstraction.
>>
>>
>> On Saturday, 26 November 2016 15:44:28 UTC, Max Goldstein wrote:
>>>
>>> What problem are you trying to solve that you can't do with Floats?
>>
>> -- 
>> 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: Whither Rationals?

2016-11-26 Thread John Watson
Nothing too complex.  I do stuff with music notation, which has the concept 
of half note, quarter note etc.  One thing I've been toying with is porting 
the Haskell School of Music 
 / Euterpea 
 to Elm. I just prefer to model 
things with the right abstraction.

On Saturday, 26 November 2016 15:44:28 UTC, Max Goldstein wrote:
>
> What problem are you trying to solve that you can't do with Floats?

-- 
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] Whither Rationals?

2016-11-26 Thread John Watson
It seems to me that a maturing language such as Elm requires first-class 
support for Rational numbers.  There is a very solid start in imeckler/ratio 
 but a couple of things are starting to 
concern me:


   - There is (as yet) no version of this library for 0.18
   - I'd like to see support for arithmetic expressions of mixed types 
   (particularly between Ints and Rationals) with unobtrusive syntax.  I 
   realise that this is tricky because of the absence of typeclasses, but I'd 
   like to know what people think might eventually be an idiomatic Elm-like 
   way to achieve this. 

Anyway, I was wondering if it were an appropriate time for elm-community to 
adopt Rationals.

-- 
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 Http regression with requests for binary resources

2016-11-18 Thread John Watson
I have a small MIDI 

 
file.  With Elm 0.17 (evancz/elm-http) I had been able to use the 
'overrideMimeType hack'  to tunnel the file through HTTP as if it were 
text.  Here's a gist 
. 
This hack no longer works 
 
in Elm 0.18 (where I have followed suggestions from elm-dev on slack simply 
to use an appropriate Accept header).  What seems to happen is that 
characters and 8-bit numbers come across unscathed but binary values larger 
than 255 do not.  This is evident in the MIDI sample from byte 23 where the 
decoded result differs from the 0.17 version.

Can anybody suggest an alternative workaround?  

-- 
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] Maybe oneOf

2016-11-18 Thread John Watson
Of course - for some reason folds had completely escaped my mind.  Thanks, 
Janis.

On Friday, 18 November 2016 11:26:11 UTC, Janis Voigtländer wrote:
>
> 2016-11-18 12:19 GMT+01:00 John Watson <john@gmx.co.uk >:
>
>  It is interesting to me that Maybe.Extra's or 
>> <http://package.elm-lang.org/packages/elm-community/maybe-extra/3.0.0/Maybe-Extra#or>
>>  
>> function is documented (quite readably) like this:
>>
>> ```elm
>> Just 4 `or` Just 5 == Just 4
>> ```
>>
>> but, of course, backticks have just been consigned to oblivion.
>>
> Well, see https://github.com/elm-community/maybe-extra/issues/28.
>
> About your question how to write something with more than two values to be 
> “or”ed: How about using List.foldl or List.foldr with Maybe.Extra.or as 
> the combining function, and your three or more values put into a list?
>
> Or, of course, use |> and either Maybe.Extra.or or Maybe.Extra.orElse.
> ​
>

-- 
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] Maybe oneOf

2016-11-18 Thread John Watson
Thanks for pointing this out.  It is interesting to me that Maybe.Extra's or 
<http://package.elm-lang.org/packages/elm-community/maybe-extra/3.0.0/Maybe-Extra#or>
 
function is documented (quite readably) like this:

```elm
Just 4 `or` Just 5 == Just 4
```

but, of course, backticks have just been consigned to oblivion.  In my 
case, I have three Maybes and I need a strict function that returns the 
first value that is actually populated (or else Nothing).  What is 
idiomatic Elm these days for doing this sort of thing:

```elm
   or Just 4 (or Just 5 Just 6)
```



On Friday, 18 November 2016 10:25:09 UTC, Janis Voigtländer wrote:
>
> See 
> https://github.com/elm-lang/core/commit/5f43ad84532bd4d462edf5c1ec22b7a62352a2db
>  
> and the comments there.
> ​
>
> 2016-11-18 10:51 GMT+01:00 John Watson <john@gmx.co.uk >:
>
>> Maybe oneOf 
>> <http://package.elm-lang.org/packages/elm-lang/core/4.0.0/Maybe#oneOf> 
>> has vanished in 0.18.  Is it intended that it will crop up somewhere in 
>> some other library or is there some sort of problem with it that I haven't 
>> tumbled to?
>>
>> -- 
>> 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] Maybe oneOf

2016-11-18 Thread John Watson
Maybe oneOf 
 has 
vanished in 0.18.  Is it intended that it will crop up somewhere in some 
other library or is there some sort of problem with it that I haven't 
tumbled to?

-- 
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 write an elm-check producer for a recursive data structure?

2016-08-17 Thread John Watson
@Max

Many thanks.  I upgraded the elm-test runner and all was fine.  Fuzzers do 
the trick when you limit the depth of recursion as in your example.  Just 
upgraded to 2.0.1 and the shrinker seems to be working much better now.

One thing I'd like to have added (if possible)

almostEqual : Float -> Float -> Expectation





On Saturday, 13 August 2016 21:52:19 UTC+1, Max Goldstein wrote:
>
> @John Yes, elm-check was deprecated earlier this will. You almost 
> certainly have an old version of the elm-test shell utility; "elm test 
> --version" should yield 0.17.1. If it doesn't,
>
> npm uninstall -g elm-test
> npm install -g elm-test
>
> "elm test init" will create the directory *tests* which will contain a 
> runner file Main.elm that you don't need to touch, and Tests.elm where you 
> put your tests.
>
> One of the big improvements over elm-check is that a fuzz test that fails 
> many times still counts as one failing test. This wasn't possible using 
> *evidenceToTest*.
>

-- 
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 write an elm-check producer for a recursive data structure?

2016-08-13 Thread John Watson
Max, I'm getting frustrated in trying to use the npm-installed elm-test 
TestRunner.  Whereas with version 1.1.0 of elm-test and elm-check, to run 
my tests  I could just use:

main =
  ElmTest.runSuite (Check.Test.evidenceToTest evidence)

it's not at all clear to me what I need to do now.  I've attempted to 
follow the instructions on the main documentation page of elm-test 2.0.0 to 
(re)-install the runner.  When I try to use elm-test init it prompts me to 
add dependencies on deadfoxygrandpa.elm-test and 
also laszlopandy/elm-console which is surely wrong.  Is it trying to 
install an old version?  I'm getting very confused.


On Saturday, 13 August 2016 10:29:14 UTC+1, John Watson wrote:
>
> Many thanks for the replies, Max and Janis.
>
> Yes - exactly - I wanted some sort of size combinator, couldn't find one 
> and just experimented to see what would happen.  It would be lovely to have 
> this built in to Fuzz.
>
> Max - many thanks for pointing out Fuzz - I wasn't aware of it. I see that 
> elm-check is now deprecated - I guess it must have happened quite recently. 
>  I'd be very happy to make the recursion depth explicit as in your second 
> example.  I'll play with it for a bit and report back what I find.  I very 
> much like the fact that you can indicate frequencies for the different ADT 
> constructors and also that (I presume) you no longer have to write your own 
> shrinkers.  I was a initially a bit concerned about *frequencyOrCrash *but 
> it seems that if you're sensible with your frequencies, then actual crashes 
> won't happen.
>
> On Friday, 12 August 2016 15:14:05 UTC+1, John Watson wrote:
>>
>> I have simplified my data type to:
>>
>> type Music =
>>   Note Int
>>   | Rest Int
>>   | Seq Music Music
>>   | Par Music Music
>>
>> I have attempted to write a Producer (see this gist 
>> <https://gist.github.com/newlandsvalley/733ced7c86b738732028b4480e83980e>) 
>> where the runtime crashes with:
>>
>> TypeError: _user$project$Producers$parseq is not a function
>>
>> If I replace the recursive generation step in the parseq 
>> <https://gist.github.com/newlandsvalley/733ced7c86b738732028b4480e83980e#file-producers-elm>
>>  
>> Producer, then I get no crash, the check works (but of course on limited 
>> data).  Judging by the lack of any log output, I don't think I'm recursing 
>> forever - I wonder if perhaps it could be another manifestation of this 
>> <https://github.com/elm-lang/elm-compiler/issues/873> problem?
>>
>> Any help gratefully accepted.
>>
>

-- 
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 write an elm-check producer for a recursive data structure?

2016-08-13 Thread John Watson
Many thanks for the replies, Max and Janis.

Yes - exactly - I wanted some sort of size combinator, couldn't find one 
and just experimented to see what would happen.  It would be lovely to have 
this built in to Fuzz.

Max - many thanks for pointing out Fuzz - I wasn't aware of it. I see that 
elm-check is now deprecated - I guess it must have happened quite recently. 
 I'd be very happy to make the recursion depth explicit as in your second 
example.  I'll play with it for a bit and report back what I find.  I very 
much like the fact that you can indicate frequencies for the different ADT 
constructors and also that (I presume) you no longer have to write your own 
shrinkers.  I was a initially a bit concerned about *frequencyOrCrash *but 
it seems that if you're sensible with your frequencies, then actual crashes 
won't happen.

On Friday, 12 August 2016 15:14:05 UTC+1, John Watson wrote:
>
> I have simplified my data type to:
>
> type Music =
>   Note Int
>   | Rest Int
>   | Seq Music Music
>   | Par Music Music
>
> I have attempted to write a Producer (see this gist 
> <https://gist.github.com/newlandsvalley/733ced7c86b738732028b4480e83980e>) 
> where the runtime crashes with:
>
> TypeError: _user$project$Producers$parseq is not a function
>
> If I replace the recursive generation step in the parseq 
> <https://gist.github.com/newlandsvalley/733ced7c86b738732028b4480e83980e#file-producers-elm>
>  
> Producer, then I get no crash, the check works (but of course on limited 
> data).  Judging by the lack of any log output, I don't think I'm recursing 
> forever - I wonder if perhaps it could be another manifestation of this 
> <https://github.com/elm-lang/elm-compiler/issues/873> problem?
>
> Any help gratefully accepted.
>

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


Re: [elm-discuss] How do I write a Producer for an ADT in elm-check?

2016-08-07 Thread John Watson
Even better.  I'd not heard of elm-search either.

On Sunday, 7 August 2016 13:48:41 UTC+1, Janis Voigtländer wrote:
>
> BTW, this was a perfect case where type based search is useful.
>
> You know what type you want, because you know the Haskell function that 
> you want an analogue for.
>
> So, go to https://klaftertief.github.io/elm-search/, enter List 
> (Generator a) -> Generator a into the search box, and you will be pointed 
> directly to the function you need.
> ​
>
> 2016-08-07 14:03 GMT+02:00 John Watson <john@gmx.co.uk >:
>
>> Ah - I see.  Many thanks, Janis.
>>
>> On Sunday, 7 August 2016 12:41:48 UTC+1, Janis Voigtländer wrote:
>>>
>>> Haskell’s `oneOf´ is Elm’s 
>>> http://package.elm-lang.org/packages/elm-community/random-extra/1.0.0/Random-Extra#choices
>>> .
>>> ​
>>>
>>> 2016-08-07 13:07 GMT+02:00 John Watson <john@gmx.co.uk>:
>>>
>>>> Suppose my ADT has four or five constructors and I want to randomly 
>>>> select one of them with equal likelihood in my Producer.  How do I do 
>>>> this? 
>>>>  (Haskell's QuickCheck has *oneOf* for example) 
>>>>
>>>> -- 
>>>> 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.


Re: [elm-discuss] How do I write a Producer for an ADT in elm-check?

2016-08-07 Thread John Watson
Ah - I see.  Many thanks, Janis.

On Sunday, 7 August 2016 12:41:48 UTC+1, Janis Voigtländer wrote:
>
> Haskell’s `oneOf´ is Elm’s 
> http://package.elm-lang.org/packages/elm-community/random-extra/1.0.0/Random-Extra#choices
> .
> ​
>
> 2016-08-07 13:07 GMT+02:00 John Watson <john@gmx.co.uk >:
>
>> Suppose my ADT has four or five constructors and I want to randomly 
>> select one of them with equal likelihood in my Producer.  How do I do this? 
>>  (Haskell's QuickCheck has *oneOf* for example) 
>>
>> -- 
>> 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] How do I write a Producer for an ADT in elm-check?

2016-08-07 Thread John Watson
Suppose my ADT has four or five constructors and I want to randomly select 
one of them with equal likelihood in my Producer.  How do I do this? 
 (Haskell's QuickCheck has *oneOf* for example) 

-- 
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: Collecting use cases for File, ArrayBuffer and TypedArrays/DataViews

2016-07-29 Thread John Watson
Hi, Daniel,  thanks for starting this off.  One thing I'd like to add:

*Binary Base64 decoders.*

These could obviously be for any binary resource that is smuggled into elm 
as text.  In my case I need to reconstitute soundfonts that are available 
as base64 encoded resources embedded in JSON.

I'm mainly interested in web-audio.  It seems to me if ever Evan (or 
somebody) gets round to doing elm-lang/web-audio, then binary types will be 
needed.  And I really would like access to web-audio (and web-midi) by 
means of a core elm library.   

On Thursday, 28 July 2016 22:17:51 UTC+1, Daniel Bachler wrote:
>
> I'd love to see support for the File and ArrayBuffer Apis, and maybe 
> TypedArrays/DataViews as well. IMHO they are an important piece of the Web 
> Platform that is still missing in Elm.
>
> Evan suggested collecting concrete use cases to guide the design. I would 
> like this thread to be the starting point of this effort. I would like to 
> ask anyone who would also like this feature or who has substantial 
> experience using either Api to add use cases or comment here so that we can 
> try to define the user story for both apis. From there, we could decide 
> what we would like to see supported and what, if anything, we don't need 
> for now and suggest Elm Apis.
>
> I have two stories from a side project of mine. It is a slideshow editor 
> that allows the user to select photos and audio files from the local 
> system, uploads them to a web service, let's the user arrange and 
> manipulate photos and music and then share the result with others. For 
> this, I have two immediate use cases plus some more ideas:
>
> *Upload local files as binary blob to AWS S3*
>
> In my current, (hacky) version, I use the FileReader api (via simonH1000's 
> filereader library) to read the content of a file into an ArrayBuffer, 
> (represented as Json.Value in Elm) then use a modified version of elm-http 
> to upload the content of the ArrayBuffer to an S3 storage bucket.
>
> *Download mp3 files, decode them and play them back via the AudioApi*
>
> Currently I do this with my modified http library to download the mp3 file 
> into an arraybuffer, then pass the resulting arraybuffer through a port to 
> some native javascript that then uses the Audio Api to decode the mp3 file 
> into a playable audiobuffer.
>
> *Parsing or otherwise processing local text files. *
>
> For another project I would be interested in reading and parsing 
> Swagger/OpenAPI definition files and then providing a UI to compare rest 
> apis. Since the processing will be done on simple Strings, this would only 
> require FileReader support (specifically the readAsText method). This would 
> already work with the FileReader library as is (though that one is not 
> available on package.elm-lang.org because it contains native code and is 
> not whitelisted).
>
> *TypedArrays and DataViews*
>
> I haven't worked with these yet, but I can anticipate some cases that 
> would be interesting:
>
> *Parsing/manipulating of binary data via the ArrayBuffer api.*
>
> One case I personally would like to do with this, is to parse the Exif 
> header of the jpeg files the user loaded from the local file system. My 
> slideshow could then display metadata information without roundtripping to 
> the server.
>
> *Create geometry for WebGL in the form of Vertex Buffers*
>
> *Generating sound/music by writing raw audio samples*
>
> These could then be played back via the Web audio apis.
>
>
> Please add your own ideas to this thread. Once we have compiled a list of 
> use cases, we can look at the JS Apis available under the Web Platform for 
> Files, ArrayBuffers, Typed Arrays etc. and think how these could be exposed 
> to Elm. 
>

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


[elm-discuss] Re: Elm for audio-reactive visuals

2016-07-25 Thread John Watson
I've been experimenting with audio quite a bit during the past few months. 
 Not sure if this is any use for you, 
but https://github.com/newlandsvalley/elm-soundfont-ports is an elm 0.17 
pseudo-library (i.e. it uses ports) which allows you to play sounds by 
means of soundfont buffers via web-audio.  

On Monday, 25 July 2016 18:52:30 UTC+1, Mike Belanger wrote:
>
> Hi guys,
>
> Recently stumbled over Elm, and I'm really digging it so far!  I 
> especially like the debugger error messages - they're really helpful!
>
> I'm looking at making graphics-related stuff (2d and 3d), and I'd like to 
> have that be coordinated with audio.  Perhaps using OSC, or maybe just 
> WebAudio.  It seems like Elm would be well suited towards this kind of 
> thing.  Unfortunately, I don't see a lot of tutorials/projects doing that 
> sort of thing.  But I suspect that's just because Elm is very new.
>
> But I want to make sure I'm not missing something critical.  Is there any 
> show-stopping things in Elm that would prevent say, beat detection, and 
> anything associated with audio-reactive components?  What about Elm's 
> ability to work with OSC and MIDI events?  I know Elm is designed as a 
> web-application, and I'm not even sure it could directly access non-HTTP 
> protocols.  I'm pretty clueless.
>
> Anyways, I'd appreciate any input/advice you guys have.  Either way Elm is 
> a pleasure to work with.
>

-- 
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: Rendering Elm in hardware

2016-07-21 Thread John Watson
I thought this was absolutely fascinating and well presented.  I'll be very 
interested to see where this leads.

On Wednesday, 20 July 2016 03:14:33 UTC+1, Luke Westby wrote:
>
> Hi folks!
>
> I wanted to share on here some code that I discussed at the July Elm 
> Remote Meetup about rendering Elm to a hardware device.
>
> All the code is at 
> https://github.com/lukewestby/elm-remote-meetup-july-2016, and the README 
> contains links to the slides and video recording of the presentation. I 
> hope it will inspire ideas about what else we can do with Elm outside of 
> the browser :)
>

-- 
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: Best practice for hover

2016-05-27 Thread John Watson
Excellent.  Thanks very much for all your help.

On 27 May 2016 at 21:44, Alexandre Galays <a...@zenexity.com> wrote:
> In that case, you're better of just using the :hover selector in CSS.
>
>
> On Friday, May 27, 2016 at 10:15:22 PM UTC+2, John Watson wrote:
>>
>> Nothing fancy - just basic styling of colour, opacity etc.
>>
>> On Friday, 27 May 2016 20:01:13 UTC+1, VeryThorough wrote:
>>>
>>> What do you want to happen on hover?  If you can give some details, I can
>>> probably tell you how to do it in CSS.
>>>
>>> On Friday, May 27, 2016 at 3:46:06 AM UTC-7, John Watson wrote:
>>>>
>>>> If I have a bunch of buttons that all need to respond to mouseOver
>>>> 'hover' in the same way, what's the best practice for implementing this in
>>>> elm?  I have so far looked at mdgriffith/elm-style-animation.  This seems
>>>> fine although I wondered if using this for such simple behaviour was
>>>> overkill.  As far as I can see I need to keep track of state for each 
>>>> button
>>>> and allocate an id to each.
>
> --
> 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/-Plv1jSG08o/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] elm-test

2016-05-19 Thread John Watson
Is there yet an elm-test binary for 0.17?

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