[elm-discuss] Elm Remote Meetup #2 videos, broken out by talk

2016-07-28 Thread Josh Adams
Hey!

So this is later than I intended it to be, but I managed to edit the videos
for the second Elm Remote Meetup and get them live.  You can find them here:


   - The whole thing:
   https://www.dailydrip.com/topics/elm-remote-meetup/drips/elm-remote-meetup-2
   - Elm Stuff, by Luke Westby:
   
https://www.dailydrip.com/topics/elm-remote-meetup/drips/elm-stuff-by-luke-westby
   - Collections and Equality: Challenge Accepted, by Robin Heggelund
   Hansen:
   
https://www.dailydrip.com/topics/elm-remote-meetup/drips/collections-and-equality-challenge-accepted-by-robin-heggelund-hansen
   - The Current State of Elm, by Noah Hall:
   
https://www.dailydrip.com/topics/elm-remote-meetup/drips/the-current-state-of-elm-by-noah-hall


Spread the love far and wide.  Hope you like it!  Thanks to all the
speakers and to everyone who attended.  If you want to help us plan the
next one, or speak at it, please just hop onto the #remote-meetup channel
on slack!

P.S. - I know there are some really annoying display bugs on these, those
are due to an edge case triggered by my rendering them on a Mac for the
first time and the hangout being at a lower resolution than I'd like,
combined with some shoddy coding on our part because we never had hit this
edge case before.  Woops!  They work/look fine once the video starts
playing.

-- 
Josh Adams

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

2016-07-28 Thread Daniel Bachler
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.


Re: [elm-discuss] Re: port module for JS interop.. without main/view ?

2016-07-28 Thread Leroy Campbell
Just to clarify, inbound messages to Elm are batched (enqueued) and then 
executed on nextTick.

And to echo Luke, observables would make more sense. A Promise-based 
interface would mean supporting only request-response semantics. 
Observables not only allow for request-response, but also publish-subscribe 
semantics.

For example, suppose you have an Elm worker that processes stock tickers. 
You send an inbound message to subscribe to one or more ticker symbols. An 
outgoing port would continue to stream updates until you send a message to 
unsubscribe from a particular ticker symbol (or all). I'm not sure how 
you'd pull that off with Promises.


On Wednesday, July 27, 2016 at 9:44:27 PM UTC-4, Yonatan Kogan wrote:
>
> For us, we have multiple inbound ports and some outbound ports (inbound to 
> elm from js, outbound to js from elm) so it's more useful.
>
> The send from Elm to JS is synchronous (newly in 0.17 I believe?) but 
> going from JS to Elm is not, as it seems like Elm waits until nextTick to 
> pick up the message (understandably). We still want to be able to say 
> "after elm has processed this" though. The analogy would be "after this 
> Ajax request has returned," so a Promise interface seems to make sense 
> (again, I know nothing about Observables).
>
> I don't think this is stable, but it does seem like the following is 
> effectively the same:
>
> ```js
> elmApp.ports.portName.send(message);
> setTimeout(function() {
>   // use newly updated data
> });
> ```
>
> Also, writing that code highlights for me that our need is somewhat 
> specific to elm updating a redux/flux store and we then want to take action 
> on the updated store.
>
> On Wed, Jul 27, 2016 at 12:36 PM, Jörg Winter  > wrote:
>
>> Just to clarify, I talk about calling Elm from JS.
>>
>> --
>> 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.
>>
>
>
>
> -- 
> Yonatan Kogan
>
>

-- 
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] Uncaught TypeError: Cannot read property 'tag' of undefined

2016-07-28 Thread Aditya Vishwakarma
Hi

I am getting Uncaught TypeError: Cannot read property 'tag' of undefined in 
a sample code I built to tryout elm. The error happen when I send JSON data 
across the elm port from JS side. 

Port 
defn: 
https://github.com/adityav/elm-reddit-listing/blob/master/src/AppPorts.elm#L14
JS call which causes this 
issue: 
https://github.com/adityav/elm-reddit-listing/blob/master/src/index.js#L36
git repo: https://github.com/adityav/elm-reddit-listing

To run. Simply do
npm install && elm package install
npm start

and open http://localhost:8080/. A listing of /r/elm should show up when 
the app works. 

A screenshot of the exact location where the error occurs:



People on slack recommended me to remove elm-stuff/build-artifacts and try 
again. It didn't work so I removed node_modules and elm-stuff directories 
and reinstalled the whole thing. Didn't work as well. 
The code was working before I decided to clean it up a little to show to my 
teammates. Stopped working the moment I shared the github link with them. :|

anyone got any ideas 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: Unit Types : A Radical Proposal

2016-07-28 Thread OvermindDL1
Could possible do it 'now' with

```elm
type Time
  = Time_Value Float

milliseconds m = seconds <| m/1000

seconds s = Time_Value s

minutes m = seconds <| m*60

from_json json =
  Json.Decode.decodeString Json.Decode.float json |> Result.map (\t -> 
Time_Value t)

to_seconds (Time_Value t) = t

to_minutes t = 60 * (to_seconds t)

to_json t = Json.Encode.float <| to_seconds t
```

If you do not expose the constructor of the type then it should be a fully 
opaque type, only able to be constructed via things like `milliseconds 500` 
or so.


On Thursday, July 28, 2016 at 12:42:44 PM UTC-6, John Bugner wrote:
>
> In the time library ( 
> package.elm-lang.org/packages/elm-lang/core/4.0.3/Time ), there are many 
> functions under the "Units" heading. Under the function `millisecond`, it 
> says:
> >Units of time, making it easier to specify things like a half-second (500 
> * millisecond) without remembering Elm’s underlying units of time.
> I find this underwhelming, because nothing forces me to use these unit 
> functions. I could write `every 5 toMsg` and the compiler will not stop me. 
> How long of a time am I actually specifying? Probably 5 milliseconds, 
> because I infer that it's probably using the same unit as JavaScript, but I 
> can't know for sure. A beginner might think 5 seconds, because it's the 
> unit that has no prefixes, or 5 minutes if 5 minutes seems appropriate to 
> what the application does. This is very bad; There should never be doubt 
> about what unit is being used, and the compiler should enforce this unit 
> correctness. Currently, Elm can't do this, because `Time` is just an alias 
> for `Float`.
>
> To prevent this kind of error, I propose a new language construct that I 
> call a "unit type". It would have the following properties:
> (1) A definition that would look (very roughly) like this:
> ```
> type unit Time as Float
> = Second
> | Millisecond == Second 0.0001
> | Nanosecond == Millisecond 0.0001
> | Minute == Second 60
> | Hour == Minute 60
> | Day == Hour 24
> | Year == Day 365
> ```
>
> The point of the definition is to:
> (a) Provide an easy way to define different units that measure the same 
> thing (in this case, time, but you could do the same thing for 
> length/height/depth in either metric or US imperial units) as constructors.
> (b) Tell how they are related to eachother. (A minute is 60 seconds, an 
> hour is 60 minutes, etc.) The compiler would check that all relations of 
> the constructors eventually flow to a single base unit (in this case, 
> `Second`). A cycle would be disallowed.
> (c) Tell what type the unit is based on (in this case, `Float`). (Perhaps 
> non-number types would be disallowed.)
>
> (2) Given that `every` still has the same signature: `Time -> (Time -> 
> msg) -> Sub msg`, `every 5 toMsg` would cause a compile-time error, because 
> the types don't match; The function expects a number with a `Time` unit, 
> but receives `5`, which is just a raw number (a number without any unit).
> (3) When writing a function that has a parameter of type `Time`, pattern 
> matching only matches the base unit constructor, not every constructor like 
> a normal (data/enum) type. The compiler would automatically convert the 
> other units to the base unit with the conversions that the programmer 
> provided in the definition.
> (4) Comparison, addition, and subtraction would be automatically 
> implemented for the type, so two times of any combination of constructors 
> could be compared, added, or subtracted with ease. `(Minute 5) - (Second 
> 20) == (Millisecond 28)` would "just work". "Time + Float" (or "Time + 
> Length") would cause a compile-time error.
> (5) Perhaps compound unit types like "Time^2" would be supported, so a 
> "Time * Time" would yield "Time^2", "Time * Float" would yield "Time", and 
> "Time * Length" would yield just that: "Time * Length". ("Force" would be 
> an alias of "Mass * Length / (Second^2)".)
>
> I know that this is a very radical proposal, (I don't know of any language 
> that has a feature like this.) but I bring it up anyways, because although 
> it's been 18 years since the mars probe crashed because of a unit error 
> (one module assumed that the number it was getting was in metric units, and 
> another assumed that it was getting it in US imperial units) ( 
> https://en.wikipedia.org/wiki/Mars_Climate_Orbiter ), I'm amazed that 
> since then, programming languages have done nothing to prevent this kind of 
> error from happening again, besides just admonishing programmers to be 
> careful. (As if the NASA programmers at the time weren't already trying to!)
>
> Letting `5` be a legal unitless `Time` value is just as silly and 
> dangerous as letting `bool a = 2;` be a legal statement in C. data/enum 
> types prevent this from happening to `Bool` in Elm, and unit types could 
> prevent the same kind of thing from happening to `Time`.
>
> Questions, comments, related thoughts, etc are

Re: [elm-discuss] Re: Unit Types : A Radical Proposal

2016-07-28 Thread Joey Eremondi
There is also some prior art with Haskell for this:

https://hackage.haskell.org/package/uom-plugin

https://hackage.haskell.org/package/units

https://hackage.haskell.org/package/Measure



On Thu, Jul 28, 2016 at 12:33 PM, Duane Johnson 
wrote:

>
> On Thu, Jul 28, 2016 at 1:11 PM, art yerkes  wrote:
>
>> F# is kind of radical in that it has units.
>>
>> https://fsharpforfunandprofit.com/posts/units-of-measure/
>>
>
> Wow, very neat! I like that F# keeps the units after the number, actually
> adding to readability.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [elm-discuss] Re: Unit Types : A Radical Proposal

2016-07-28 Thread Duane Johnson
On Thu, Jul 28, 2016 at 1:11 PM, art yerkes  wrote:

> F# is kind of radical in that it has units.
>
> https://fsharpforfunandprofit.com/posts/units-of-measure/
>

Wow, very neat! I like that F# keeps the units after the number, actually
adding to readability.

-- 
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: Unit Types : A Radical Proposal

2016-07-28 Thread art yerkes
F# is kind of radical in that it has units.

https://fsharpforfunandprofit.com/posts/units-of-measure/

It's not perfect, but it could serve as a starting point for evaluating 
different ways of having units as part of a language.

On Thursday, July 28, 2016 at 11:42:44 AM UTC-7, John Bugner wrote:
>
> In the time library ( 
> package.elm-lang.org/packages/elm-lang/core/4.0.3/Time ), there are many 
> functions under the "Units" heading. Under the function `millisecond`, it 
> says:
> >Units of time, making it easier to specify things like a half-second (500 
> * millisecond) without remembering Elm’s underlying units of time.
> I find this underwhelming, because nothing forces me to use these unit 
> functions. I could write `every 5 toMsg` and the compiler will not stop me. 
> How long of a time am I actually specifying? Probably 5 milliseconds, 
> because I infer that it's probably using the same unit as JavaScript, but I 
> can't know for sure. A beginner might think 5 seconds, because it's the 
> unit that has no prefixes, or 5 minutes if 5 minutes seems appropriate to 
> what the application does. This is very bad; There should never be doubt 
> about what unit is being used, and the compiler should enforce this unit 
> correctness. Currently, Elm can't do this, because `Time` is just an alias 
> for `Float`.
>
> To prevent this kind of error, I propose a new language construct that I 
> call a "unit type". It would have the following properties:
> (1) A definition that would look (very roughly) like this:
> ```
> type unit Time as Float
> = Second
> | Millisecond == Second 0.0001
> | Nanosecond == Millisecond 0.0001
> | Minute == Second 60
> | Hour == Minute 60
> | Day == Hour 24
> | Year == Day 365
> ```
>
> The point of the definition is to:
> (a) Provide an easy way to define different units that measure the same 
> thing (in this case, time, but you could do the same thing for 
> length/height/depth in either metric or US imperial units) as constructors.
> (b) Tell how they are related to eachother. (A minute is 60 seconds, an 
> hour is 60 minutes, etc.) The compiler would check that all relations of 
> the constructors eventually flow to a single base unit (in this case, 
> `Second`). A cycle would be disallowed.
> (c) Tell what type the unit is based on (in this case, `Float`). (Perhaps 
> non-number types would be disallowed.)
>
> (2) Given that `every` still has the same signature: `Time -> (Time -> 
> msg) -> Sub msg`, `every 5 toMsg` would cause a compile-time error, because 
> the types don't match; The function expects a number with a `Time` unit, 
> but receives `5`, which is just a raw number (a number without any unit).
> (3) When writing a function that has a parameter of type `Time`, pattern 
> matching only matches the base unit constructor, not every constructor like 
> a normal (data/enum) type. The compiler would automatically convert the 
> other units to the base unit with the conversions that the programmer 
> provided in the definition.
> (4) Comparison, addition, and subtraction would be automatically 
> implemented for the type, so two times of any combination of constructors 
> could be compared, added, or subtracted with ease. `(Minute 5) - (Second 
> 20) == (Millisecond 28)` would "just work". "Time + Float" (or "Time + 
> Length") would cause a compile-time error.
> (5) Perhaps compound unit types like "Time^2" would be supported, so a 
> "Time * Time" would yield "Time^2", "Time * Float" would yield "Time", and 
> "Time * Length" would yield just that: "Time * Length". ("Force" would be 
> an alias of "Mass * Length / (Second^2)".)
>
> I know that this is a very radical proposal, (I don't know of any language 
> that has a feature like this.) but I bring it up anyways, because although 
> it's been 18 years since the mars probe crashed because of a unit error 
> (one module assumed that the number it was getting was in metric units, and 
> another assumed that it was getting it in US imperial units) ( 
> https://en.wikipedia.org/wiki/Mars_Climate_Orbiter ), I'm amazed that 
> since then, programming languages have done nothing to prevent this kind of 
> error from happening again, besides just admonishing programmers to be 
> careful. (As if the NASA programmers at the time weren't already trying to!)
>
> Letting `5` be a legal unitless `Time` value is just as silly and 
> dangerous as letting `bool a = 2;` be a legal statement in C. data/enum 
> types prevent this from happening to `Bool` in Elm, and unit types could 
> prevent the same kind of thing from happening to `Time`.
>
> Questions, comments, related thoughts, etc are welcome.
>
>

-- 
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] Unit Types : A Radical Proposal

2016-07-28 Thread Duane Johnson
This would be a nice fix to the Radians / Degrees issue too. Every language
seems to settle on one or the other as "the base unit" but newcomers have
to learn the assumption or face bad accidental outputs.

On Thu, Jul 28, 2016 at 12:42 PM, John Bugner  wrote:

> In the time library (
> package.elm-lang.org/packages/elm-lang/core/4.0.3/Time ), there are many
> functions under the "Units" heading. Under the function `millisecond`, it
> says:
> >Units of time, making it easier to specify things like a half-second (500
> * millisecond) without remembering Elm’s underlying units of time.
> I find this underwhelming, because nothing forces me to use these unit
> functions. I could write `every 5 toMsg` and the compiler will not stop me.
> How long of a time am I actually specifying? Probably 5 milliseconds,
> because I infer that it's probably using the same unit as JavaScript, but I
> can't know for sure. A beginner might think 5 seconds, because it's the
> unit that has no prefixes, or 5 minutes if 5 minutes seems appropriate to
> what the application does. This is very bad; There should never be doubt
> about what unit is being used, and the compiler should enforce this unit
> correctness. Currently, Elm can't do this, because `Time` is just an alias
> for `Float`.
>
> To prevent this kind of error, I propose a new language construct that I
> call a "unit type". It would have the following properties:
> (1) A definition that would look (very roughly) like this:
> ```
> type unit Time as Float
> = Second
> | Millisecond == Second 0.0001
> | Nanosecond == Millisecond 0.0001
> | Minute == Second 60
> | Hour == Minute 60
> | Day == Hour 24
> | Year == Day 365
> ```
>
> The point of the definition is to:
> (a) Provide an easy way to define different units that measure the same
> thing (in this case, time, but you could do the same thing for
> length/height/depth in either metric or US imperial units) as constructors.
> (b) Tell how they are related to eachother. (A minute is 60 seconds, an
> hour is 60 minutes, etc.) The compiler would check that all relations of
> the constructors eventually flow to a single base unit (in this case,
> `Second`). A cycle would be disallowed.
> (c) Tell what type the unit is based on (in this case, `Float`). (Perhaps
> non-number types would be disallowed.)
>
> (2) Given that `every` still has the same signature: `Time -> (Time ->
> msg) -> Sub msg`, `every 5 toMsg` would cause a compile-time error, because
> the types don't match; The function expects a number with a `Time` unit,
> but receives `5`, which is just a raw number (a number without any unit).
> (3) When writing a function that has a parameter of type `Time`, pattern
> matching only matches the base unit constructor, not every constructor like
> a normal (data/enum) type. The compiler would automatically convert the
> other units to the base unit with the conversions that the programmer
> provided in the definition.
> (4) Comparison, addition, and subtraction would be automatically
> implemented for the type, so two times of any combination of constructors
> could be compared, added, or subtracted with ease. `(Minute 5) - (Second
> 20) == (Millisecond 28)` would "just work". "Time + Float" (or "Time +
> Length") would cause a compile-time error.
> (5) Perhaps compound unit types like "Time^2" would be supported, so a
> "Time * Time" would yield "Time^2", "Time * Float" would yield "Time", and
> "Time * Length" would yield just that: "Time * Length". ("Force" would be
> an alias of "Mass * Length / (Second^2)".)
>
> I know that this is a very radical proposal, (I don't know of any language
> that has a feature like this.) but I bring it up anyways, because although
> it's been 18 years since the mars probe crashed because of a unit error
> (one module assumed that the number it was getting was in metric units, and
> another assumed that it was getting it in US imperial units) (
> https://en.wikipedia.org/wiki/Mars_Climate_Orbiter ), I'm amazed that
> since then, programming languages have done nothing to prevent this kind of
> error from happening again, besides just admonishing programmers to be
> careful. (As if the NASA programmers at the time weren't already trying to!)
>
> Letting `5` be a legal unitless `Time` value is just as silly and
> dangerous as letting `bool a = 2;` be a legal statement in C. data/enum
> types prevent this from happening to `Bool` in Elm, and unit types could
> prevent the same kind of thing from happening to `Time`.
>
> Questions, comments, related thoughts, etc are welcome.
>
> --
> 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 
Discus

[elm-discuss] Unit Types : A Radical Proposal

2016-07-28 Thread John Bugner
In the time library ( 
package.elm-lang.org/packages/elm-lang/core/4.0.3/Time ), there are many 
functions under the "Units" heading. Under the function `millisecond`, it 
says:
>Units of time, making it easier to specify things like a half-second (500 
* millisecond) without remembering Elm’s underlying units of time.
I find this underwhelming, because nothing forces me to use these unit 
functions. I could write `every 5 toMsg` and the compiler will not stop me. 
How long of a time am I actually specifying? Probably 5 milliseconds, 
because I infer that it's probably using the same unit as JavaScript, but I 
can't know for sure. A beginner might think 5 seconds, because it's the 
unit that has no prefixes, or 5 minutes if 5 minutes seems appropriate to 
what the application does. This is very bad; There should never be doubt 
about what unit is being used, and the compiler should enforce this unit 
correctness. Currently, Elm can't do this, because `Time` is just an alias 
for `Float`.

To prevent this kind of error, I propose a new language construct that I 
call a "unit type". It would have the following properties:
(1) A definition that would look (very roughly) like this:
```
type unit Time as Float
= Second
| Millisecond == Second 0.0001
| Nanosecond == Millisecond 0.0001
| Minute == Second 60
| Hour == Minute 60
| Day == Hour 24
| Year == Day 365
```

The point of the definition is to:
(a) Provide an easy way to define different units that measure the same 
thing (in this case, time, but you could do the same thing for 
length/height/depth in either metric or US imperial units) as constructors.
(b) Tell how they are related to eachother. (A minute is 60 seconds, an 
hour is 60 minutes, etc.) The compiler would check that all relations of 
the constructors eventually flow to a single base unit (in this case, 
`Second`). A cycle would be disallowed.
(c) Tell what type the unit is based on (in this case, `Float`). (Perhaps 
non-number types would be disallowed.)

(2) Given that `every` still has the same signature: `Time -> (Time -> msg) 
-> Sub msg`, `every 5 toMsg` would cause a compile-time error, because the 
types don't match; The function expects a number with a `Time` unit, but 
receives `5`, which is just a raw number (a number without any unit).
(3) When writing a function that has a parameter of type `Time`, pattern 
matching only matches the base unit constructor, not every constructor like 
a normal (data/enum) type. The compiler would automatically convert the 
other units to the base unit with the conversions that the programmer 
provided in the definition.
(4) Comparison, addition, and subtraction would be automatically 
implemented for the type, so two times of any combination of constructors 
could be compared, added, or subtracted with ease. `(Minute 5) - (Second 
20) == (Millisecond 28)` would "just work". "Time + Float" (or "Time + 
Length") would cause a compile-time error.
(5) Perhaps compound unit types like "Time^2" would be supported, so a 
"Time * Time" would yield "Time^2", "Time * Float" would yield "Time", and 
"Time * Length" would yield just that: "Time * Length". ("Force" would be 
an alias of "Mass * Length / (Second^2)".)

I know that this is a very radical proposal, (I don't know of any language 
that has a feature like this.) but I bring it up anyways, because although 
it's been 18 years since the mars probe crashed because of a unit error 
(one module assumed that the number it was getting was in metric units, and 
another assumed that it was getting it in US imperial units) ( 
https://en.wikipedia.org/wiki/Mars_Climate_Orbiter ), I'm amazed that since 
then, programming languages have done nothing to prevent this kind of error 
from happening again, besides just admonishing programmers to be careful. 
(As if the NASA programmers at the time weren't already trying to!)

Letting `5` be a legal unitless `Time` value is just as silly and dangerous 
as letting `bool a = 2;` be a legal statement in C. data/enum types prevent 
this from happening to `Bool` in Elm, and unit types could prevent the same 
kind of thing from happening to `Time`.

Questions, comments, related thoughts, etc are welcome.

-- 
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: Form with union type

2016-07-28 Thread Yosuke Torii
Hi Simone,

I wrote the fixed version here 
 (copy & 
paste to Try Elm ).
Union type was not wrong. The `on` function assumes an event object to be 
decoded, but you expect a string.
So I used `targetValue` decoder, which is a shortcut for `e.target.value`.


2016年7月28日木曜日 0時25分46秒 UTC+9 Simone Vittori:
>
> I'm building a language selector and I'd like to map the options to a 
> union type.
>
> Here's what I tried:
>
> import Json.Decode exposing (Decoder, customDecoder, string)
>
> {-| Currently supported languages. -}
> type Language
> = English
> | Japanese
>
>
> {-| A JSON decoder of Language. -}
> languageDecoder : Decoder Language
> languageDecoder =
> customDecoder string fromStringLanguage
>
>
> fromStringLanguage : String -> Result String Language
> fromStringLanguage str =
> case str of
> "English" -> Ok English
> "Japanese" -> Ok Japanese
> other -> Err ("Invalid language: " ++ other)
>
> And here's how I'm using it:
>
> -- MODEL
>
> type alias Model = Language
>
>
> -- UPDATE
>
> type Msg
> = Change Language
>
> update : Msg -> Model -> Model
> update msg model =
> case msg of
> Change language -> language
>
>
> -- VIEW
>
> view : Model -> Html Msg
> view model =
> Html.form []
> [ select [ on "change" <| Json.Decode.map Change languageDecoder ]
> (List.map (viewOption model) ["English", "Japanese"])
> ]
>
> It does compile successfully, but when I select another option from the 
> dropdown list, nothing happens. Any ideas?
> Is this the right way of decoding a union type?
>

-- 
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: Is there a way to investigate a Html tree?

2016-07-28 Thread Yosuke Torii
Recently I wrote a little parser for `toString` representation.

https://github.com/jinjor/elm-time-travel/blob/master/src/TimeTravel/Internal/Parser/Parser.elm

It turns
toString <| div [] [ input [ type' "text", class "foo", onClick 1 ] [], 
text "hello" ]

into
Record ([Property "type" (StringLiteral "node"),Property "tag" (
StringLiteral "div"),Property "facts" (Record []),Property "children" (
Record ([Property "0" (Record ([Property "type" (StringLiteral "node"),
Property "tag" (StringLiteral "input"),Property "facts" (Record ([Property 
"type" (StringLiteral "text"),Property "className" (StringLiteral "foo"),
Property "EVENT" (Record ([Property "click" (Record ([Property "options" (
Record ([Property "stopPropagation" (Union "False" []),Property 
"preventDefault" (Union "False" [])])),Property "decoder" (Value ""
)]))]))])),Property "children" (Record []),Property "namespace" (Value 
""),Property "descendantsCount" (Value "0")])),Property "1" (Record 
([Property "type" (StringLiteral "text"),Property "text" (StringLiteral 
"hello")]))])),Property "namespace" (Value ""),Property 
"descendantsCount" (Value "2")])

Peter, is this close to what you want to do?


2016年7月28日木曜日 18時21分58秒 UTC+9 Peter Damoc:
>
> I need to gather all the class names used in a Html tree generated by the 
> app. 
>
> Is there a way to do this short of converting the html to a string and 
> manually parsing it? 
>
>  
>
>
>
> -- 
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>

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


Re: [elm-discuss] Is there a way to investigate a Html tree?

2016-07-28 Thread Conrad Dean
I've been trying to figure out how to do this with elm-markdown objects as
well, but haven't gotten anywhere with it.

On Thu, Jul 28, 2016 at 8:06 AM, Noah Hall  wrote:

> Hope. This is what I tried first, but toString sadly does things to js
>  objects that make that hard. The rest of the helpers in that file are
> dedicated to trying to get that to work, actually. By replacing and
> collecting fields and properties.
>
>
> On Thursday, July 28, 2016, Peter Damoc  wrote:
>
>> Will calling toString on a Html element render it or will it print the
>> internal representation?
>>
>> I'm trying to avoid going to Native, if possible.
>>
>>
>>
>> On Thu, Jul 28, 2016 at 2:39 PM, Noah Hall  wrote:
>>
>>> It turns the internal representation to a string representation. It
>>> doesn't actually render it at that point. It's just the internal
>>> representation.
>>>
>>>
>>> On Thursday, July 28, 2016, Peter Damoc  wrote:
>>>
 I took quick look and I got here:

 https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Helpers.elm#L31

 query leads to nodeTypeFromHtml which is actually living in a module
 named HtmlToString :)

 Looks like you are still turning it into a string.
 I'm imagining that with the help of that native, the string
 representation is smarter (ready for Json decoding)

 Am I missing something or misreading the code?




 On Thu, Jul 28, 2016 at 1:46 PM, Noah Hall  wrote:

> My implementation of server-side rendering allows you to do exactly
> that, without turning it to a string.
>
> Checkout how this is implemented ->
>
> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51
>
> On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc 
> wrote:
> > I need to gather all the class names used in a Html tree generated
> by the
> > app.
> >
> > Is there a way to do this short of converting the html to a string
> and
> > manually parsing it?
> >
> >
> >
> >
> >
> > --
> > There is NO FATE, we are the creators.
> > blog: http://damoc.ro/
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "Elm Discuss" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an
> > email to elm-discuss+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

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

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

-- 
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: Modifying the DOM with external JS libraries

2016-07-28 Thread Marco Perone
Thanks Ian, elm-markdown did the trick!

2016-07-28 0:46 GMT+02:00 Ian Mackenzie :

> In this particular case, if you're just using highlight.js to highlight a
> block of code, you might also be able to use evancz/elm-markdown (
> http://package.elm-lang.org/packages/evancz/elm-markdown/3.0.0/). You'll
> still need to load a version of highlight.js in your HTML as described by
> the elm-markdown README, but then you should just be able to render a
> Markdown fragment containing a code block without worrying about weird DOM
> interactions.
>
> --
> 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/JrrIWHZDckU/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] Is there a way to investigate a Html tree?

2016-07-28 Thread Noah Hall
Hope. This is what I tried first, but toString sadly does things to js
 objects that make that hard. The rest of the helpers in that file are
dedicated to trying to get that to work, actually. By replacing and
collecting fields and properties.

On Thursday, July 28, 2016, Peter Damoc  wrote:

> Will calling toString on a Html element render it or will it print the
> internal representation?
>
> I'm trying to avoid going to Native, if possible.
>
>
>
> On Thu, Jul 28, 2016 at 2:39 PM, Noah Hall  > wrote:
>
>> It turns the internal representation to a string representation. It
>> doesn't actually render it at that point. It's just the internal
>> representation.
>>
>>
>> On Thursday, July 28, 2016, Peter Damoc > > wrote:
>>
>>> I took quick look and I got here:
>>>
>>> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Helpers.elm#L31
>>>
>>> query leads to nodeTypeFromHtml which is actually living in a module
>>> named HtmlToString :)
>>>
>>> Looks like you are still turning it into a string.
>>> I'm imagining that with the help of that native, the string
>>> representation is smarter (ready for Json decoding)
>>>
>>> Am I missing something or misreading the code?
>>>
>>>
>>>
>>>
>>> On Thu, Jul 28, 2016 at 1:46 PM, Noah Hall  wrote:
>>>
 My implementation of server-side rendering allows you to do exactly
 that, without turning it to a string.

 Checkout how this is implemented ->

 https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51

 On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc  wrote:
 > I need to gather all the class names used in a Html tree generated by
 the
 > app.
 >
 > Is there a way to do this short of converting the html to a string and
 > manually parsing it?
 >
 >
 >
 >
 >
 > --
 > There is NO FATE, we are the creators.
 > blog: http://damoc.ro/
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups
 > "Elm Discuss" group.
 > To unsubscribe from this group and stop receiving emails from it,
 send an
 > email to elm-discuss+unsubscr...@googlegroups.com.
 > For more options, visit https://groups.google.com/d/optout.

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

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

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


[elm-discuss] Re: Search Selection widget

2016-07-28 Thread Erkal Selman
In other words, I want to prevent the default behaviour not for all 
keypresses but only for up and down arrow keypresses. Is this possible?

On Thursday, July 28, 2016 at 1:55:18 PM UTC+2, Erkal Selman wrote:
>
> I don't understand. What do you mean by *"handle those keys inside the 
> input field"*?
>
> The problem is that if we prevent the default arrow key behaviour with 
> preventDefault, writing into the input field is also prevented.
>
>
>
> On Thursday, July 28, 2016 at 1:33:00 PM UTC+2, Zeljko Nesic wrote:
>>
>> I today had a plan of rewriting my dropdown component from Angular to 
>> Elm, which was inspired by SemanticUI's one. 
>>
>> Anyway, my solution was handle those keys inside the input field. 
>>
>> Also, make sure, just to preventDefault, and let propagation fall 
>> through. == { stopPropagation = False , preventDefault = True }
>>
>> hope this helps
>>
>> On Monday, February 15, 2016 at 8:29:59 PM UTC+1, Bernd Meyer wrote:
>>>
>>> I'm trying to create a search selection widget like 
>>> http://semantic-ui.com/modules/dropdown.html#search-selection in elm. I 
>>> would the user to be able to browse through the options using the arrow 
>>> keys. In order to avoid scrolling in the browser when an arrow key is 
>>> pressed I'm using onWithOptions with preventDefault True. This seems to 
>>> work however, but the input functionality is broken since all keystrokes 
>>> are consumed by the key handler. Here is the relevant part of the code.
>>>
>>> handleKey: List String ->  Int -> Action
 handleKey options code =
   case code of
 13 -> Submit (List.head options)
 27 -> Close
 _  -> NoOp
 
 openDropdown : Signal.Address Action -> Model -> List String -> Html
 openDropdown address model options =
 div [ attribute "aria-label" "Filter venue"
 , class "ui search selection dropdown active visible"
 , onWithOptions "keydown" evOptions keyCode (\code -> 
 Signal.message address (handleKey options code))
 ]
   [ i [ class "dropdown icon" ] []
   , input 
 [ on "input" targetValue (Signal.message address << Update)
 , placeholder model.value
 , tabindex 0] []
   , div [ class "text" ] [ text model.inputValue ]
   , div [ class "menu transition visible", attribute "style" 
 "display: block !important;", tabindex -1 ]
   (itemsView address model.value filtered)
   ]
>>>
>>>
>>>

-- 
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] Exporting an event stream

2016-07-28 Thread Zachary Kessin
I know the idea of having an event stream that can be exported and replayed
has been kicked around a bit for a while. Has anyone ever done anything
with this?

Ideally I would like to be able to generate a sequence of events with a
QuickCheck type tool (either in elm or erlang)

Zach

-- 
Zach Kessin
SquareTarget 
Twitter: @zkessin 
Skype: zachkessin
ᐧ

-- 
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: Search Selection widget

2016-07-28 Thread Erkal Selman
I don't understand. What do you mean by *"handle those keys inside the 
input field"*?

The problem is that if we prevent the default arrow key behaviour with 
preventDefault, writing into the input field is also prevented.



On Thursday, July 28, 2016 at 1:33:00 PM UTC+2, Zeljko Nesic wrote:
>
> I today had a plan of rewriting my dropdown component from Angular to Elm, 
> which was inspired by SemanticUI's one. 
>
> Anyway, my solution was handle those keys inside the input field. 
>
> Also, make sure, just to preventDefault, and let propagation fall through. 
> == { stopPropagation = False , preventDefault = True }
>
> hope this helps
>
> On Monday, February 15, 2016 at 8:29:59 PM UTC+1, Bernd Meyer wrote:
>>
>> I'm trying to create a search selection widget like 
>> http://semantic-ui.com/modules/dropdown.html#search-selection in elm. I 
>> would the user to be able to browse through the options using the arrow 
>> keys. In order to avoid scrolling in the browser when an arrow key is 
>> pressed I'm using onWithOptions with preventDefault True. This seems to 
>> work however, but the input functionality is broken since all keystrokes 
>> are consumed by the key handler. Here is the relevant part of the code.
>>
>> handleKey: List String ->  Int -> Action
>>> handleKey options code =
>>>   case code of
>>> 13 -> Submit (List.head options)
>>> 27 -> Close
>>> _  -> NoOp
>>> 
>>> openDropdown : Signal.Address Action -> Model -> List String -> Html
>>> openDropdown address model options =
>>> div [ attribute "aria-label" "Filter venue"
>>> , class "ui search selection dropdown active visible"
>>> , onWithOptions "keydown" evOptions keyCode (\code -> 
>>> Signal.message address (handleKey options code))
>>> ]
>>>   [ i [ class "dropdown icon" ] []
>>>   , input 
>>> [ on "input" targetValue (Signal.message address << Update)
>>> , placeholder model.value
>>> , tabindex 0] []
>>>   , div [ class "text" ] [ text model.inputValue ]
>>>   , div [ class "menu transition visible", attribute "style" 
>>> "display: block !important;", tabindex -1 ]
>>>   (itemsView address model.value filtered)
>>>   ]
>>
>>
>>

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


Re: [elm-discuss] Is there a way to investigate a Html tree?

2016-07-28 Thread Peter Damoc
Will calling toString on a Html element render it or will it print the
internal representation?

I'm trying to avoid going to Native, if possible.



On Thu, Jul 28, 2016 at 2:39 PM, Noah Hall  wrote:

> It turns the internal representation to a string representation. It
> doesn't actually render it at that point. It's just the internal
> representation.
>
>
> On Thursday, July 28, 2016, Peter Damoc  wrote:
>
>> I took quick look and I got here:
>>
>> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Helpers.elm#L31
>>
>> query leads to nodeTypeFromHtml which is actually living in a module
>> named HtmlToString :)
>>
>> Looks like you are still turning it into a string.
>> I'm imagining that with the help of that native, the string
>> representation is smarter (ready for Json decoding)
>>
>> Am I missing something or misreading the code?
>>
>>
>>
>>
>> On Thu, Jul 28, 2016 at 1:46 PM, Noah Hall  wrote:
>>
>>> My implementation of server-side rendering allows you to do exactly
>>> that, without turning it to a string.
>>>
>>> Checkout how this is implemented ->
>>>
>>> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51
>>>
>>> On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc  wrote:
>>> > I need to gather all the class names used in a Html tree generated by
>>> the
>>> > app.
>>> >
>>> > Is there a way to do this short of converting the html to a string and
>>> > manually parsing it?
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> > There is NO FATE, we are the creators.
>>> > blog: http://damoc.ro/
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Elm Discuss" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> > email to elm-discuss+unsubscr...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Elm Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to elm-discuss+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

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


Re: [elm-discuss] Is there a way to investigate a Html tree?

2016-07-28 Thread Noah Hall
It turns the internal representation to a string representation. It doesn't
actually render it at that point. It's just the internal representation.

On Thursday, July 28, 2016, Peter Damoc  wrote:

> I took quick look and I got here:
>
> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Helpers.elm#L31
>
> query leads to nodeTypeFromHtml which is actually living in a module named
> HtmlToString :)
>
> Looks like you are still turning it into a string.
> I'm imagining that with the help of that native, the string representation
> is smarter (ready for Json decoding)
>
> Am I missing something or misreading the code?
>
>
>
>
> On Thu, Jul 28, 2016 at 1:46 PM, Noah Hall  > wrote:
>
>> My implementation of server-side rendering allows you to do exactly
>> that, without turning it to a string.
>>
>> Checkout how this is implemented ->
>>
>> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51
>>
>> On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc > > wrote:
>> > I need to gather all the class names used in a Html tree generated by
>> the
>> > app.
>> >
>> > Is there a way to do this short of converting the html to a string and
>> > manually parsing it?
>> >
>> >
>> >
>> >
>> >
>> > --
>> > There is NO FATE, we are the creators.
>> > blog: http://damoc.ro/
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Elm Discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to elm-discuss+unsubscr...@googlegroups.com
>> 
>> .
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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: Search Selection widget

2016-07-28 Thread Zeljko Nesic
I today had a plan of rewriting my dropdown component from Angular to Elm, 
which was inspired by SemanticUI's one. 

Anyway, my solution was handle those keys inside the input field. 

Also, make sure, just to preventDefault, and let propagation fall through. 
== { stopPropagation = False , preventDefault = True }

hope this helps

On Monday, February 15, 2016 at 8:29:59 PM UTC+1, Bernd Meyer wrote:
>
> I'm trying to create a search selection widget like 
> http://semantic-ui.com/modules/dropdown.html#search-selection in elm. I 
> would the user to be able to browse through the options using the arrow 
> keys. In order to avoid scrolling in the browser when an arrow key is 
> pressed I'm using onWithOptions with preventDefault True. This seems to 
> work however, but the input functionality is broken since all keystrokes 
> are consumed by the key handler. Here is the relevant part of the code.
>
> handleKey: List String ->  Int -> Action
>> handleKey options code =
>>   case code of
>> 13 -> Submit (List.head options)
>> 27 -> Close
>> _  -> NoOp
>> 
>> openDropdown : Signal.Address Action -> Model -> List String -> Html
>> openDropdown address model options =
>> div [ attribute "aria-label" "Filter venue"
>> , class "ui search selection dropdown active visible"
>> , onWithOptions "keydown" evOptions keyCode (\code -> 
>> Signal.message address (handleKey options code))
>> ]
>>   [ i [ class "dropdown icon" ] []
>>   , input 
>> [ on "input" targetValue (Signal.message address << Update)
>> , placeholder model.value
>> , tabindex 0] []
>>   , div [ class "text" ] [ text model.inputValue ]
>>   , div [ class "menu transition visible", attribute "style" 
>> "display: block !important;", tabindex -1 ]
>>   (itemsView address model.value filtered)
>>   ]
>
>
>

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


Re: [elm-discuss] Is there a way to investigate a Html tree?

2016-07-28 Thread Peter Damoc
I took quick look and I got here:
https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Helpers.elm#L31

query leads to nodeTypeFromHtml which is actually living in a module named
HtmlToString :)

Looks like you are still turning it into a string.
I'm imagining that with the help of that native, the string representation
is smarter (ready for Json decoding)

Am I missing something or misreading the code?




On Thu, Jul 28, 2016 at 1:46 PM, Noah Hall  wrote:

> My implementation of server-side rendering allows you to do exactly
> that, without turning it to a string.
>
> Checkout how this is implemented ->
>
> https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51
>
> On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc  wrote:
> > I need to gather all the class names used in a Html tree generated by the
> > app.
> >
> > Is there a way to do this short of converting the html to a string and
> > manually parsing it?
> >
> >
> >
> >
> >
> > --
> > There is NO FATE, we are the creators.
> > blog: http://damoc.ro/
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Elm Discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to elm-discuss+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

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


Re: [elm-discuss] Is there a way to investigate a Html tree?

2016-07-28 Thread Noah Hall
My implementation of server-side rendering allows you to do exactly
that, without turning it to a string.

Checkout how this is implemented ->
https://github.com/eeue56/elm-server-side-renderer/blob/master/src/Query.elm#L51

On Thu, Jul 28, 2016 at 11:21 AM, Peter Damoc  wrote:
> I need to gather all the class names used in a Html tree generated by the
> app.
>
> Is there a way to do this short of converting the html to a string and
> manually parsing it?
>
>
>
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


[elm-discuss] Re: Search Selection widget

2016-07-28 Thread Erkal Selman
I am also interested in the answer.
Does anyone know a solution (for 0.17)?

On Monday, February 15, 2016 at 8:29:59 PM UTC+1, Bernd Meyer wrote:
>
> I'm trying to create a search selection widget like 
> http://semantic-ui.com/modules/dropdown.html#search-selection in elm. I 
> would the user to be able to browse through the options using the arrow 
> keys. In order to avoid scrolling in the browser when an arrow key is 
> pressed I'm using onWithOptions with preventDefault True. This seems to 
> work however, but the input functionality is broken since all keystrokes 
> are consumed by the key handler. Here is the relevant part of the code.
>
> handleKey: List String ->  Int -> Action
>> handleKey options code =
>>   case code of
>> 13 -> Submit (List.head options)
>> 27 -> Close
>> _  -> NoOp
>> 
>> openDropdown : Signal.Address Action -> Model -> List String -> Html
>> openDropdown address model options =
>> div [ attribute "aria-label" "Filter venue"
>> , class "ui search selection dropdown active visible"
>> , onWithOptions "keydown" evOptions keyCode (\code -> 
>> Signal.message address (handleKey options code))
>> ]
>>   [ i [ class "dropdown icon" ] []
>>   , input 
>> [ on "input" targetValue (Signal.message address << Update)
>> , placeholder model.value
>> , tabindex 0] []
>>   , div [ class "text" ] [ text model.inputValue ]
>>   , div [ class "menu transition visible", attribute "style" 
>> "display: block !important;", tabindex -1 ]
>>   (itemsView address model.value filtered)
>>   ]
>
>
>

-- 
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] Is there a way to investigate a Html tree?

2016-07-28 Thread Peter Damoc
I need to gather all the class names used in a Html tree generated by the
app.

Is there a way to do this short of converting the html to a string and
manually parsing it?





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

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


[elm-discuss] Looking for a contract doing Elm (possibly with Erlang or Elixir)

2016-07-28 Thread Zachary Kessin
Hi  All
I have been developing on elm for about 8 months and have been doing Erlang
since about 2011. I was wondering if anyone needs a developer for a project?

Zach

-- 
Zach Kessin
Twitter: @zkessin 
Skype: zachkessin
ᐧ

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