Re: [elm-discuss] No Runtime Exceptions - Still not computing

2016-10-06 Thread Max Goldstein
Yes, Result is worth looking at. It's like Maybe, except the error case can 
carry some information too (usually a string). Task is used for 
asynchronous effects (e.g. HTTP requests) which often can fail in odd ways. 
I'd focus on Result for now, as all the tooling I'm about to mention is the 
same across these types.

Joey mentioned we like to map over arrays. Well, you can also map over a 
Maybe or a Result. The trick is that these are also data structures; they 
just happen to hold at most one (successful) element. So you find yourself 
doing things like

String.parseInt "not an integer"
|> Result.map doSomethingWithTheInt
|> Result.andThen doSomethingWithTheIntThatCouldFail

This way you build up pipelines that ignore the fact that you don't 
actually have an integer. The error short-circuits the pipeline and gets 
handled at the end, so it's like throwing in that you can handle the error 
at a distance. And you can collapse many errors into one case that you 
handle all in one place. (minor detail: this is using the argument order 
for andThen coming in 0.18)

I few weeks ago I had to add a lot of try...catch blocks around someone 
else's code, and let me tell you, it wasn't fun.

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


Re: [elm-discuss] What is canonical way to import CSS?

2016-10-06 Thread Aaron VonderHaar
Hello,

Afaik, the canonical way is to have a wrapper HTML file.  If you are
concerned about losing fast reloading in elm-reactor, you can use
https://github.com/tomekwi/elm-live which can inject live reloading into
your HTML wrapper when developing!  The HTML wrapper can be as simple as:






  
  Elm.Main.fullscreen();



It's conceivable that you could use elm-html to make Elm render a style tag
into your page that references a css file to avoid having an HTML wrapper
either by making a 

Re: [elm-discuss] No Runtime Exceptions - Still not computing

2016-10-06 Thread Ambrose Laing
Elm has datatypes called Maybe, Result and Task.  You mentioned Maybe 
already, which may be understood to mean a list of at most one item, or a 
data type with either missing data, or an unspecified error.  Result allows 
you to specify the error and propagate it, so take a look at that.  Then 
look at Task also.

http://package.elm-lang.org/packages/elm-lang/core/4.0.5/Result

On Thursday, October 6, 2016 at 11:33:43 PM UTC-4, Dave Ford wrote:
>
> Duane. Don't get me wrong. I prefer compile errors over runtime errors.  
> And if Elm can catch more errors at compile time without adding a bunch of 
> noise to my code that is a good thing obviously.
>
> But runtime errors are unavoidable.  It's not possible for the compiler to 
> catch every possible error condition. The question is,  does the language 
> have an elegant mechanism to deal with runtime exceptions? Especially in a 
> separate flow from the normal return value. 
>
> And from what I am hearing the answer is either no or no one is telling me 
> what it is.  
>
> So my question is: does Elm have something similar to throw/raise?
>
> On Oct 6, 2016 8:07 PM, "Duane Johnson" > 
> wrote:
>
>>
>> On Thu, Oct 6, 2016 at 8:13 PM, Dave Ford > > wrote:
>>
>>> 2. *Runtime Exception. *Like a NullPointerException or an 
>>> IllegalArgumentException. I *love* these kind of bugs. Super easy to 
>>> find. Super easy to fix. A stack trace tells me exactly where to look. 
>>> These kind of exceptions have never been a thorn in my spine.
>>
>>
>> I'm genuinely surprised by your experience / reaction to runtime 
>> exceptions. My experience has been the exact opposite. Runtime exceptions 
>> can only be found through tedious exercise of every branch of code through 
>> all possible states, which creates a horrible burden on the developer who 
>> wishes to not have to worry about how old code might break as new code is 
>> added and the size of the project (and possible states) increases.
>>
>> When you say you love these kind of bugs, are you saying you like to go 
>> through your program and try this or that input and see if you can get it 
>> to throw an exception? What if you change the code somewhere else, but in a 
>> section of code that *might* affect other parts of your codebase--do you 
>> then go back to each of the other parts of your program and try to think of 
>> new ways that exceptions might have be able to be raised?
>>
>> I wrote part of a large (very large--possibly the largest open source 
>> Ruby app, called Canvas) and at some point, the complexity becomes 
>> mindboggling. It slows down project development when you can't check (at 
>> compile-time) whether a change here affects the code *there* (and *there*, 
>> and *there*, and, does it affect *this* code?) The motivation of Elm, as I 
>> see it, is to push as many classes of errors as possible into the 
>> compile-time error space. Not all can be pushed into that domain, but many 
>> can--and that's considered an advantage because as project size increases, 
>> you can still move with confidence.
>>
>> Possibly related--I found it instructive to listen to Richard's "Making 
>> Impossible States Impossible" presentation at ElmConf.
>>
>> -- 
>> 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/00CgYDiMvBI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: [elm-discuss] No Runtime Exceptions - Still not computing

2016-10-06 Thread Dave Ford
Duane. Don't get me wrong. I prefer compile errors over runtime errors.
And if Elm can catch more errors at compile time without adding a bunch of
noise to my code that is a good thing obviously.

But runtime errors are unavoidable.  It's not possible for the compiler to
catch every possible error condition. The question is,  does the language
have an elegant mechanism to deal with runtime exceptions? Especially in a
separate flow from the normal return value.

And from what I am hearing the answer is either no or no one is telling me
what it is.

So my question is: does Elm have something similar to throw/raise?

On Oct 6, 2016 8:07 PM, "Duane Johnson"  wrote:

>
> On Thu, Oct 6, 2016 at 8:13 PM, Dave Ford  wrote:
>
>> 2. *Runtime Exception. *Like a NullPointerException or an
>> IllegalArgumentException. I *love* these kind of bugs. Super easy to
>> find. Super easy to fix. A stack trace tells me exactly where to look.
>> These kind of exceptions have never been a thorn in my spine.
>
>
> I'm genuinely surprised by your experience / reaction to runtime
> exceptions. My experience has been the exact opposite. Runtime exceptions
> can only be found through tedious exercise of every branch of code through
> all possible states, which creates a horrible burden on the developer who
> wishes to not have to worry about how old code might break as new code is
> added and the size of the project (and possible states) increases.
>
> When you say you love these kind of bugs, are you saying you like to go
> through your program and try this or that input and see if you can get it
> to throw an exception? What if you change the code somewhere else, but in a
> section of code that *might* affect other parts of your codebase--do you
> then go back to each of the other parts of your program and try to think of
> new ways that exceptions might have be able to be raised?
>
> I wrote part of a large (very large--possibly the largest open source Ruby
> app, called Canvas) and at some point, the complexity becomes mindboggling.
> It slows down project development when you can't check (at compile-time)
> whether a change here affects the code *there* (and *there*, and *there*,
> and, does it affect *this* code?) The motivation of Elm, as I see it, is to
> push as many classes of errors as possible into the compile-time error
> space. Not all can be pushed into that domain, but many can--and that's
> considered an advantage because as project size increases, you can still
> move with confidence.
>
> Possibly related--I found it instructive to listen to Richard's "Making
> Impossible States Impossible" presentation at ElmConf.
>
> --
> 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/00CgYDiMvBI/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] What is canonical way to import CSS?

2016-10-06 Thread Michael Hipp
Hello. Learning Elm. Very impressed with the work being done here.

Wanting to give my app a somewhat polished look, so thought to use an 
outboard CSS library/framework. What is the canonical way to import a CSS 
file into an Elm program? (I'd prefer not to have a "wrapper" HTML document 
but rather write a pure Elm program if possible.)

Thanks.

-- 
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] No Runtime Exceptions - Still not computing

2016-10-06 Thread Duane Johnson
On Thu, Oct 6, 2016 at 8:13 PM, Dave Ford  wrote:

> 2. *Runtime Exception. *Like a NullPointerException or an
> IllegalArgumentException. I *love* these kind of bugs. Super easy to
> find. Super easy to fix. A stack trace tells me exactly where to look.
> These kind of exceptions have never been a thorn in my spine.


I'm genuinely surprised by your experience / reaction to runtime
exceptions. My experience has been the exact opposite. Runtime exceptions
can only be found through tedious exercise of every branch of code through
all possible states, which creates a horrible burden on the developer who
wishes to not have to worry about how old code might break as new code is
added and the size of the project (and possible states) increases.

When you say you love these kind of bugs, are you saying you like to go
through your program and try this or that input and see if you can get it
to throw an exception? What if you change the code somewhere else, but in a
section of code that *might* affect other parts of your codebase--do you
then go back to each of the other parts of your program and try to think of
new ways that exceptions might have be able to be raised?

I wrote part of a large (very large--possibly the largest open source Ruby
app, called Canvas) and at some point, the complexity becomes mindboggling.
It slows down project development when you can't check (at compile-time)
whether a change here affects the code *there* (and *there*, and *there*,
and, does it affect *this* code?) The motivation of Elm, as I see it, is to
push as many classes of errors as possible into the compile-time error
space. Not all can be pushed into that domain, but many can--and that's
considered an advantage because as project size increases, you can still
move with confidence.

Possibly related--I found it instructive to listen to Richard's "Making
Impossible States Impossible" presentation at ElmConf.

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread John Mayer
It's difficult to assess the performance anecdotally (benchmarks are
preferred, see Evan's meticulous blog posts around Elm's performance
relative to other languages/libraries/frameworks)

My view is that we don't need Polymer, just the web components standards.
If you're deploying to production, that may means that you may need to
serve browser poly-fills.

Regardless, later phases of the Elm/Web Component experiment will have a
few simple benchmarks.

On Thu, Oct 6, 2016 at 10:45 PM, Aislan de Sousa Maia <
aislan.sousam...@gmail.com> wrote:

> I've heard scary things about Polymer performance, mainly on mobile
> browsers. What you guys think about the state of Polymer at this time?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] No Runtime Exceptions - Still not computing

2016-10-06 Thread Dave Ford
Thanks Joey.


> you will handle the error case, and either come up with a sensible
> default, or tell your program to display some error message, or do
> something else to properly handle the error.
>
You mean, do exactly like I showed in the java newbie example? What would
be considered an anti-pattern in java? How is this a good thing? It seems
like a step backwards.

Often there is no way to "handle" the error. There is no sensible default.
It's a programmer error and throwing an exception is the most logical thing
to do.

Unless I am missing some key concept, this will make your programs less
reliable. True, there will be no runtime exception. But there will be bugs.
And more noise.

Again, I will admit that I am new to Elm. And may be missing something. I
totally get the whole "maybe" thing. And I see the advantage of that.

But, if I am not mistaken, we are back to C in the sense of "no throw"? C#,
Java, JavaScript, and Scala have the keyword throw. VisualBasic, Python,
Ruby, F# and Clojure have raise.

Is there no throw/raise in Elm? We must use "return" for both standard
return and error return. Is that correct?

I'm not trying to be a troll. There are lots of things I love about Elm.
I'm just trying to understand the language. Thanks.

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread Aislan de Sousa Maia
I've heard scary things about Polymer performance, mainly on mobile 
browsers. What you guys think about the state of Polymer at this time?

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


Re: [elm-discuss] No Runtime Exceptions - Still not computing

2016-10-06 Thread Joey Eremondi
What actually happens is "no uncaught runtime exceptions".

If an operation can fail, it *MUST* be expressed in the type, and when you
call the operation, you *MUST* handle the failure case.

Your program will never crash because of a null pointer or file-not-found
or an array out of bounds, but it also will not fail silently unless you go
out of your way to make it do so. What will happen is you will handle the
error case, and either come up with a sensible default, or tell your
program to display some error message, or do something else to properly
handle the error.

It means that there's no forgetting to check the error codes, like you get
in C all the time. And there most certainly will not be an "undefined is
not a function" nested deep in some complex operation chain, as you get all
the time with JS.

Take a look at Array.get:
http://package.elm-lang.org/packages/elm-lang/core/latest/Array#get

If you have an array of T, instead of returning a T with the possibility of
a crash, it returns a Maybe T. The programmer is forced to check if there
was an array-out-of-bounds error. The program will not compile otherwise.

(That said, in the common case, like iterating through a whole array,
there's Array.map, which never fails, because it only looks at array
elements that are actually there).

On Thu, Oct 6, 2016 at 7:13 PM, Dave Ford  wrote:

> I have listened to a number of podcasts where Richard Feldman boasts
> about never getting a runtime exception.
>
> I am having a hard time grasping the concept. I think I look at runtime
> exceptions a bit differently. I look at them as a *positive*. A
> programmers tool. A debugging tool. A way to communicate up the call stack.
> A way to separate the error stream from the standard stream.
>
> For example, a java newbie might do this:
>
> void myFunction(int x){
>if(x < 1){
> *  log("error: x must be >= 1"); *
> *  return 0*
>}
>return x * x * x;
> }
>
> A more experienced developer might do this:
>
> void myFunction(int x){
>if(x < 1){
>   *throw new IllegalArgumentException("error: x must be >= 1"); *
>}
>return x * x * x;
> }
>
> I look at runtime exceptions as a good thing. It's kind of like having two
> returns. One return for the normal answer (return). And another for error
> conditions (throw). Just like unix has two output streams: one for normal
> messages and one for error messages. This allows the caller to handle the
> normal return value and the *top-level* caller to handle (i.e. catch) the
> errors (usually by logging a stack trace).
>
> So I don't get it. If I don't have runtime exceptions, what do I do when
> someone passes an invalid argument? What do I do if some pre-condition is
> not as I expected? Some JSON returned from the server is not in the correct
> format? Are we back to just *one* return value for both error conditions
> and normal conditions?
>
> Technically speaking, in java, if I wanted to create an app with no
> runtime exceptions it would be real easy. I could just swallow invalid
> arguments and let the program fail in a super mysterious way, farther
> upstream (the opposite of fail-fast). But I wouldn't boast about that. Or I
> could just have a try/catch in my main method that caught every exception
> and swallowed it or logged it.
>
> If Richard said he wrote apps with no *bugs*. That would be impressive.
> But an app with no runtime exceptions seems like a silly thing to boast
> about. I see 3 kinds of bugs in my java apps:
>
> 1. *Compile errors.* These are the easiest to deal with. These are
> preferred. But I don't see the compiler catching the above mentioned
> IllegalArgumentException*. *Or a piece of bad JSON from the server.
>
> 2. *Runtime Exception. *Like a NullPointerException or an
> IllegalArgumentException. I *love* these kind of bugs. Super easy to
> find. Super easy to fix. A stack trace tells me exactly where to look.
> These kind of exceptions have never been a thorn in my spine.
>
> 3. *The mystery bug. *Program is just not producing the correct output.
> No idea why. No idea where to start looking. No error message. No stack
> trace. These are the worst kind of errors.
>
> In my opinion one of the key differences between an experienced developer
> and a beginner developer is that an experienced developer fails-fast with
> compile errors (#1) or runtime exceptions (#2). Beginner developers fail
> mysteriously with (#3).
>
> So, based on my understanding, the whole "no runtime exceptions" concept
> is just not computing.
>
> But I am new to Elm. Surely I am misunderstanding something. Please tell
> me what I am missing.
>
>
> --
> 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 

[elm-discuss] No Runtime Exceptions - Still not computing

2016-10-06 Thread Dave Ford
I have listened to a number of podcasts where Richard Feldman boasts about 
never getting a runtime exception. 

I am having a hard time grasping the concept. I think I look at runtime 
exceptions a bit differently. I look at them as a *positive*. A programmers 
tool. A debugging tool. A way to communicate up the call stack. A way to 
separate the error stream from the standard stream.

For example, a java newbie might do this:

void myFunction(int x){
   if(x < 1){
*  log("error: x must be >= 1"); *
*  return 0*
   }  
   return x * x * x;
}

A more experienced developer might do this:

void myFunction(int x){
   if(x < 1){
  *throw new IllegalArgumentException("error: x must be >= 1"); *
   }  
   return x * x * x;
}

I look at runtime exceptions as a good thing. It's kind of like having two 
returns. One return for the normal answer (return). And another for error 
conditions (throw). Just like unix has two output streams: one for normal 
messages and one for error messages. This allows the caller to handle the 
normal return value and the *top-level* caller to handle (i.e. catch) the 
errors (usually by logging a stack trace). 

So I don't get it. If I don't have runtime exceptions, what do I do when 
someone passes an invalid argument? What do I do if some pre-condition is 
not as I expected? Some JSON returned from the server is not in the correct 
format? Are we back to just *one* return value for both error conditions 
and normal conditions?

Technically speaking, in java, if I wanted to create an app with no 
runtime exceptions it would be real easy. I could just swallow invalid 
arguments and let the program fail in a super mysterious way, farther 
upstream (the opposite of fail-fast). But I wouldn't boast about that. Or I 
could just have a try/catch in my main method that caught every exception 
and swallowed it or logged it.

If Richard said he wrote apps with no *bugs*. That would be impressive. But 
an app with no runtime exceptions seems like a silly thing to boast about. 
I see 3 kinds of bugs in my java apps:

1. *Compile errors.* These are the easiest to deal with. These are 
preferred. But I don't see the compiler catching the above mentioned 
IllegalArgumentException*. *Or a piece of bad JSON from the server.

2. *Runtime Exception. *Like a NullPointerException or an 
IllegalArgumentException. I *love* these kind of bugs. Super easy to find. 
Super easy to fix. A stack trace tells me exactly where to look. These kind 
of exceptions have never been a thorn in my spine. 

3. *The mystery bug. *Program is just not producing the correct output. No 
idea why. No idea where to start looking. No error message. No stack trace. 
These are the worst kind of errors.

In my opinion one of the key differences between an experienced developer 
and a beginner developer is that an experienced developer fails-fast with 
compile errors (#1) or runtime exceptions (#2). Beginner developers fail 
mysteriously with (#3).

So, based on my understanding, the whole "no runtime exceptions" concept is 
just not computing.

But I am new to Elm. Surely I am misunderstanding something. Please tell me 
what I am missing.


-- 
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] Making tangram logos

2016-10-06 Thread Aaron VonderHaar
For anyone who's been wanting an easy way to make nice-looking tangram
logos for their own Elm projects, I did a short livestream last week where
I made a small Elm module with some nice helper functions for quickly
assembling SVG tangram shapes.

Code is here: https://github.com/ElmLive/tangram-logo

You can watch me make a camera tangram for my ElmLive logo (takes just
under 10 minutes):  https://youtu.be/eMxwECIC7mc?t=47m56s

And you can watch the full video (~1hr) to see how I built the helper
functions: https://youtu.be/eMxwECIC7mc

(And apologies for the noisy audio in the recordings--I hadn't quite
figured out the best way to do the audio post-processing when I did this.)


Examples of the end results:
[image: Inline image 2]  [image: Inline image 1]

Example of what the resulting code looks like:

```
main : Svg msg
main =
let
big1 =
triangle 2
|> rotate 90

big2 =
triangle 2
|> rotate -90
|> snap 2 (to big1 3)

med =
triangle (sqrt 2)
|> rotate 225
|> snap 1 (to big1 2)
|> add ( 0, 0.5 )

par =
parallelogram
|> rotate 90
|> Pieces.flip
|> snap 3 (to med 1)
in
svg [ viewBox "-4 -5 10 10" ]
[ triangle 1
|> rotate 180
|> snap 2 (to big1 2)
|> draw colors.orange
, square
|> snap 3 (to big2 1)
|> draw colors.green
, triangle 1
|> rotate 0
|> snap 3 (to big2 1)
|> draw colors.orange
, med
|> draw colors.blue
, par
|> draw colors.green
, big1
|> draw colors.gray
, big2
|> draw colors.blue
]
```

-- 
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: Installing Elm Packages while Offline

2016-10-06 Thread Aislan de Sousa Maia
It should be great if this installing tool was like the rails's bundle 
command tool. Just have the packages downloaded into a local location, and 
when you need this stuffs installed, get through your own already installed 
packages with the installing tool. No necessary to copy and past from a 
previous project.

-- 
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: Functional programming, or why should I use Elm instead of vanilla javaScript?

2016-10-06 Thread Zinggi
> And all this stuff about immutability, can be easily achieved in plain 
javaScript. 

You claim that you can achieve all the the things that elm does by being 
disciplined enough, but that's not true. Here are a few things that only 
elm can provide that JavaScript can't.
These things are only possible because of elms limitations:

  - Easy serialization/deserialization of application state *including 
state from external libraries*
  - *Enforced semantic versioning* for all packages
  - A sane package ecosystem
  - A time traveling debugger *that works no matter what code you write or 
libraries you use*
  - *No runtime exceptions*

So by removing a bunch of features from JavaScript, namely mutable 
variables and arbitrary side effects, elm can provide all the above. 

On Wednesday, 5 October 2016 19:50:52 UTC+2, Sarkis Arutiunian wrote:
>
> Recently I read article about Functional programming, all 5 parts 
> .
>  
> Yes it's pretty interesting article, written in interesting way. And I 
> really like pattern of 'functional programming', immutability and etc.
>
>
> But there is a question. Where the line between propriety and paranoia?
>
>
> I prefer use native javaScript for everything where I can do it without 
> any libraries. Yes exactly you should use some UI libraries like React and 
> some module bundler like webpack. But I think propriety of using this tools 
> is obvious. It's better to use JSX then use native js to create DOM or it's 
> better to use webpack at least to uglify and optimize your code because 
> some things just impossible to achieve without webpack.
>
> And we have absolutely opposite situation with Elm. Yes they have some 
> features to make function a little bit shorter than you'll do it in vanilla 
> javaScript and only in some case. It's not that difference like create 
> nodes with JSX or js.
>
>
> And all this stuff about immutability, can be easily achieved in plain 
> javaScript. Eventually is Elm code will be converted to plain javaScript 
> and not vice versa, so that's mean you can do all that stuff in javaScript 
> but for sure there are some features in javaScript which you can't do in 
> Elm. And using Elm you are limited with one pattern. And what if it's not 
> enough or it's not best solution in some case, what than? For example right 
> now I'm working on new CMS for one of my projects, on React/GraphQL/Nodejs 
> and hybrid storage MongoDb with mySQL. I would like to use this pattern in 
> some cases but I just can't use it everywhere, so that's mean I shouldn't 
> use Elm?
>
>
> Don't think that I'm against to Elm. I just want to see opinion of others. 
> And I want to see that line, between propriety and paranoia.
>
>
> Thanks.
>

-- 
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 to interpret missing fields as Nothing in ports?

2016-10-06 Thread Aaron VonderHaar
At NoRedInk, if we are passing complex data through a port, we generally
pass it as `Json.Value`, and then use a JSON decoder in Elm to transform it
into the appropriate type.  That way, you can write a decoder to handle
missing fields in whatever way you'd like.

On Thu, Oct 6, 2016 at 11:18 AM, Ed Ilyin  wrote:

> Hi,
>
> When you send record with Maybe fields to a port - Nothing values are
> converted to nulls.
> When you send json with null properties to firebase - firebase removes
> such properties (by design)
> When you try to receive record from port - how to force Elm to interpret
> missing fields as Nothing?
>
> I have seen old https://github.com/elm-lang/elm-plans/issues/17 and
> https://github.com/elm-lang/elm-compiler/issues/1007 issues
>
> What can I do except making conversion of each object in javascript?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Thursday, October 6, 2016 at 3:54:02 PM UTC+1, Peter Damoc wrote:
>
> Next challenge: how to implement Custom Elements in Elm. :) 
>
>
These examples cover a variety of different ways of working with elm and 
polymer together:

https://github.com/kevinlebrun/elm-polymer

This one, I think, is a polymer component implemented with elm:

https://github.com/kevinlebrun/elm-polymer/tree/master/counter-elm-inside-polymer

>

-- 
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] Has anyone integrated Elm into a Web Forms project?

2016-10-06 Thread Kasey Speakman
I have a legacy project that needs a new page. I'm just trying to figure 
out the logistics of getting Elm to work with the existing (full) Visual 
Studio project. If someone has done that already, I would greatly 
appreciate hearing your experiences.

-- 
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 to interpret missing fields as Nothing in ports?

2016-10-06 Thread Ed Ilyin
Hi,

When you send record with Maybe fields to a port - Nothing values are 
converted to nulls.
When you send json with null properties to firebase - firebase removes such 
properties (by design)
When you try to receive record from port - how to force Elm to interpret 
missing fields as Nothing?

I have seen old https://github.com/elm-lang/elm-plans/issues/17 
and https://github.com/elm-lang/elm-compiler/issues/1007 issues

What can I do except making conversion of each object in javascript?

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


Re: [elm-discuss] Installing Elm Packages while Offline

2016-10-06 Thread Duane Johnson
Well, that's easy.

On Thu, Oct 6, 2016 at 10:53 AM, Aaron VonderHaar 
wrote:

> Yes, you can just copy the relevant packages in the
> `./elm-stuff/packages/` folders of your projects.
>
> On Thu, Oct 6, 2016 at 9:36 AM, Duane Johnson 
> wrote:
>
>> I'll be taking a long flight tomorrow and I'm curious if there's an easy
>> way to install packages without the `elm package install` tool, which seems
>> to require internet access.
>>
>> For instance, if I have a new project, and a "package" installed in
>> another project that I've previously worked on, is there a way to install
>> the package using the other directory as the "source" (rather than the
>> internet)?
>>
>> Duane
>>
>> --
>> 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] Installing Elm Packages while Offline

2016-10-06 Thread Aaron VonderHaar
Yes, you can just copy the relevant packages in the `./elm-stuff/packages/`
folders of your projects.

On Thu, Oct 6, 2016 at 9:36 AM, Duane Johnson 
wrote:

> I'll be taking a long flight tomorrow and I'm curious if there's an easy
> way to install packages without the `elm package install` tool, which seems
> to require internet access.
>
> For instance, if I have a new project, and a "package" installed in
> another project that I've previously worked on, is there a way to install
> the package using the other directory as the "source" (rather than the
> internet)?
>
> Duane
>
> --
> 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] Problem with beginnerProgram

2016-10-06 Thread Aaron VonderHaar
Hello,

The error is saying that your view is producing messages that are
functions.  This is because your `onClick` is using `UpdateModel`, but
`UpdateModel` itself is not a message: `UpdateModel` needs a String value
to become a Msg.

Possible fixes would be:

1) Change UpdateModel to not take any parameters:

type Msg = UpdateModel

2) Pass a string to UpdateModel in your onClick:

button [ onClick (UpdateModel "ValueToSend") ] [ text "Ajouter" ]



On Thu, Oct 6, 2016 at 4:50 AM, Did  wrote:

> Hi there,
>
> I'm pretty new to elm and I'm facing an issue I can't resolve by myself...
>
> I would like to display a text entered in a textbox by clicking on a
> button. But elm detects an error with the definition of view. It says :
>
> -
>
> Detected errors in 1 module.
>
>
> -- TYPE MISMATCH --
> -
>
> The type annotation for `view` does not match its definition.
>
> 26| view: String -> Html a
>   
> The type annotation is saying:
>
> String -> Html a
>
> But I am inferring that the definition has this type:
>
> String -> Html (String -> Msg)
>
> Hint: A type annotation is too generic. You can probably just switch to
> the type
> I inferred. These issues can be subtle though, so read more about it.
>  hints/type-annotations.md>
>
> ---
>
> I really don't know what to do. If you can please explain how to resolve
> this, because I can't find anything that helps... Thanks for your time!
>
> Here is the code I wrote in http://elm-lang.org/try :
>
> import Html exposing (..)
> import Html.App as App
> import Html.Attributes exposing (..)
> import Html.Events exposing (..)
>
> main =
>   App.beginnerProgram {
> model = init "",
> update = update,
> view = view
>   }
>
> init : String -> String
> init str =
>   str
>
> type Msg = UpdateModel String
>
> update: Msg -> String -> String
> update action model =
>   case action of
> UpdateModel newModel ->
>   newModel
>
> view: String -> Html a
> view model =
>   div[]
>   [
> input[type' "text", placeholder "Please enter a name..."][]
>,button [onClick UpdateModel][text "Ajouter"]
>,div[][text model]
>   ]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [elm-discuss] Problem with beginnerProgram

2016-10-06 Thread Duane Johnson
Right here, you're saying that the UpdateModel type takes a String:

> type Msg = UpdateModel String
>
> update: Msg -> String -> String
> update action model =
>   case action of
> UpdateModel newModel ->
>   newModel
>
> view: String -> Html a
> view model =
>   div[]
>   [
> input[type' "text", placeholder "Please enter a name..."][]
>

But over here, you're not providing UpdateModel with a string:

>,button [onClick UpdateModel][text "Ajouter"]
>,div[][text model]
>   ]
>

The "onClick" event is just a did-it-happen event, it provides no
additional information. So the type system is detecting that there's a
mismatch. Try replacing your `view` function with this:

view : String -> Html Msg
> view model =
> div []
> [ input [ type' "text", placeholder "Please enter a name..." ] []
> , button [ onClick (UpdateModel "Ajouter") ] [ text "Ajouter" ]
> , div [] [ text model ]
> ]

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


[elm-discuss] Problem with beginnerProgram

2016-10-06 Thread Did
Hi there,

I'm pretty new to elm and I'm facing an issue I can't resolve by myself...

I would like to display a text entered in a textbox by clicking on a 
button. But elm detects an error with the definition of view. It says :

-

Detected errors in 1 module.


-- TYPE MISMATCH 
---

The type annotation for `view` does not match its definition.

26| view: String -> Html a
  
The type annotation is saying:

String -> Html a

But I am inferring that the definition has this type:

String -> Html (String -> Msg)

Hint: A type annotation is too generic. You can probably just switch to the 
type
I inferred. These issues can be subtle though, so read more about it.


---

I really don't know what to do. If you can please explain how to resolve 
this, because I can't find anything that helps... Thanks for your time!

Here is the code I wrote in http://elm-lang.org/try :

import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)

main =
  App.beginnerProgram {
model = init "",
update = update,
view = view
  }

init : String -> String
init str =
  str

type Msg = UpdateModel String

update: Msg -> String -> String
update action model =
  case action of
UpdateModel newModel ->
  newModel
  
view: String -> Html a
view model =
  div[]
  [
input[type' "text", placeholder "Please enter a name..."][]
   ,button [onClick UpdateModel][text "Ajouter"] 
   ,div[][text model]
  ]

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


[elm-discuss] Installing Elm Packages while Offline

2016-10-06 Thread Duane Johnson
I'll be taking a long flight tomorrow and I'm curious if there's an easy
way to install packages without the `elm package install` tool, which seems
to require internet access.

For instance, if I have a new project, and a "package" installed in another
project that I've previously worked on, is there a way to install the
package using the other directory as the "source" (rather than the
internet)?

Duane

-- 
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: Which text editor do you prefer for Elm?

2016-10-06 Thread Dave Thomas
Im pretty much using VSCode for everything in Elm, with some occasional use 
of LightTable with the elm-light plugin which is very nice too.

-- 
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: Functional programming, or why should I use Elm instead of vanilla javaScript?

2016-10-06 Thread Joey Eremondi
You can get good code without Elm's type system, but what you won't get is
a compiler as an assistant.

Made a small typo? The compiler tells you. Mixed up the first and second
arguments to a function? Usually a type error, so the compiler tells you.

Most importantly, refactoring becomes easy. You changed the interface or
return type of a function? The compiler will literally tell you every place
in your code that needs to be changed because of this. You can have
confidence that refactoring won't break everything, because if it compiles,
there's *no possible way* to get a type error at runtime. (Except for an
ever shrinking list of obscure corner cases).

On Thu, Oct 6, 2016 at 2:41 AM, Zachary Kessin  wrote:

> I think this is true of compilers in general. There are a number of scheme
> compilers that output C code out there, I expect if you took the output of
> one of them and looked at it vs hand written C they would look very
> different.
>
> Zach
> ᐧ
>
> On Thu, Oct 6, 2016 at 12:22 PM, Will White 
> wrote:
>
>> Have you seen the JS that Elm compiles to? I've attached what Elm TodoMVC
>>  compiles to. Here's the one of
>> the first functions:
>>
>> function F2(fun)
>> {
>>   function wrapper(a) { return function(b) { return fun(a,b); }; }
>>   wrapper.arity = 2;
>>   wrapper.func = fun;
>>   return wrapper;
>> }
>>
>>
>> It's JS, but it's not the kind of application code I'd write in JS. My
>> point is that Elm application code is really on another level.
>>
>>
>> On Wednesday, October 5, 2016 at 6:50:52 PM UTC+1, Sarkis Arutiunian
>> wrote:
>>>
>>> Recently I read article about Functional programming, all 5 parts
>>> .
>>> Yes it's pretty interesting article, written in interesting way. And I
>>> really like pattern of 'functional programming', immutability and etc.
>>>
>>>
>>> But there is a question. Where the line between propriety and paranoia?
>>>
>>>
>>> I prefer use native javaScript for everything where I can do it without
>>> any libraries. Yes exactly you should use some UI libraries like React and
>>> some module bundler like webpack. But I think propriety of using this tools
>>> is obvious. It's better to use JSX then use native js to create DOM or it's
>>> better to use webpack at least to uglify and optimize your code because
>>> some things just impossible to achieve without webpack.
>>>
>>> And we have absolutely opposite situation with Elm. Yes they have some
>>> features to make function a little bit shorter than you'll do it in vanilla
>>> javaScript and only in some case. It's not that difference like create
>>> nodes with JSX or js.
>>>
>>>
>>> And all this stuff about immutability, can be easily achieved in plain
>>> javaScript. Eventually is Elm code will be converted to plain javaScript
>>> and not vice versa, so that's mean you can do all that stuff in javaScript
>>> but for sure there are some features in javaScript which you can't do in
>>> Elm. And using Elm you are limited with one pattern. And what if it's not
>>> enough or it's not best solution in some case, what than? For example right
>>> now I'm working on new CMS for one of my projects, on React/GraphQL/Nodejs
>>> and hybrid storage MongoDb with mySQL. I would like to use this pattern in
>>> some cases but I just can't use it everywhere, so that's mean I shouldn't
>>> use Elm?
>>>
>>>
>>> Don't think that I'm against to Elm. I just want to see opinion of
>>> others. And I want to see that line, between propriety and paranoia.
>>>
>>>
>>> Thanks.
>>>
>> --
>> 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.
>>
>
>
>
> --
> 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.
>

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread John Orford
This is brilliant, hope someone can write this all up for reference at some
stage. ;)
On Thu, 6 Oct 2016 at 16:53, Peter Damoc  wrote:

> Next challenge: how to implement Custom Elements in Elm. :)
>
>
> On Thu, Oct 6, 2016 at 5:42 PM, 'Rupert Smith' via Elm Discuss <
> elm-discuss@googlegroups.com> wrote:
>
> On Thursday, October 6, 2016 at 12:23:53 PM UTC+1, Peter Damoc wrote:
>
> This works for me in both Chrome and Firefox on OS X with
> the  'webcomponents-lite.js'
>
> Thanks for solving this.
>
>
> After some poking around and a severe lack of documentation on the part of
> Polymer, I have managed to hook into the select events like this:
>
> root : Model -> Html Msg
> root model =
> div
> [ class "layout-fixed-width" ]
> [ div []
> [ h4 [] [ text "Multi-select" ]
> , Html.Keyed.node "div"
> [ class "horizontal-section" ]
> [ ( "listbox"
>   , paperListBox
> [ attribute "multi" ""
> , attribute "attr-for-selected" "value"
> , on "iron-select" (selectedDecoder |> Decode.map
> Selected)
> ]
> [ paperItem [ value "0" ] [ text "Bold" ]
> , paperItem [ value "1" ] [ text "Italic" ]
> , paperItem [ value "2" ] [ text "Underline" ]
> , paperItem [ value "3" ] [ text "Strikethrough" ]
> ]
>   )
> ]
> ]
> ]
>
>
> selectedDecoder : Decode.Decoder (Result String Int)
> selectedDecoder =
> Decode.at [ "detail", "item", "value" ] Decode.string |> Decode.map
> String.toInt
>
> That is, applying "on" to "iron-select", setting values on the items in
> the list, and then using "at" from Json.Decode to drill down to where the
> value is in the event.
>
> There's no stoppin' us now!
>
> --
> 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.


Re: [elm-discuss] Re: Integrating Elm with Web Components / Polymer

2016-10-06 Thread Peter Damoc
Next challenge: how to implement Custom Elements in Elm. :)


On Thu, Oct 6, 2016 at 5:42 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Thursday, October 6, 2016 at 12:23:53 PM UTC+1, Peter Damoc wrote:
>>
>> This works for me in both Chrome and Firefox on OS X with
>> the  'webcomponents-lite.js'
>>
>> Thanks for solving this.
>>
>
> After some poking around and a severe lack of documentation on the part of
> Polymer, I have managed to hook into the select events like this:
>
> root : Model -> Html Msg
> root model =
> div
> [ class "layout-fixed-width" ]
> [ div []
> [ h4 [] [ text "Multi-select" ]
> , Html.Keyed.node "div"
> [ class "horizontal-section" ]
> [ ( "listbox"
>   , paperListBox
> [ attribute "multi" ""
> , attribute "attr-for-selected" "value"
> , on "iron-select" (selectedDecoder |> Decode.map
> Selected)
> ]
> [ paperItem [ value "0" ] [ text "Bold" ]
> , paperItem [ value "1" ] [ text "Italic" ]
> , paperItem [ value "2" ] [ text "Underline" ]
> , paperItem [ value "3" ] [ text "Strikethrough" ]
> ]
>   )
> ]
> ]
> ]
>
>
> selectedDecoder : Decode.Decoder (Result String Int)
> selectedDecoder =
> Decode.at [ "detail", "item", "value" ] Decode.string |> Decode.map
> String.toInt
>
> That is, applying "on" to "iron-select", setting values on the items in
> the list, and then using "at" from Json.Decode to drill down to where the
> value is in the event.
>
> There's no stoppin' us now!
>
>> --
> 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] Re: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Thursday, October 6, 2016 at 12:23:53 PM UTC+1, Peter Damoc wrote:
>
> This works for me in both Chrome and Firefox on OS X with 
> the  'webcomponents-lite.js' 
>
> Thanks for solving this. 
>

After some poking around and a severe lack of documentation on the part of 
Polymer, I have managed to hook into the select events like this:

root : Model -> Html Msg
root model =
div
[ class "layout-fixed-width" ]
[ div []
[ h4 [] [ text "Multi-select" ]
, Html.Keyed.node "div"
[ class "horizontal-section" ]
[ ( "listbox"
  , paperListBox
[ attribute "multi" ""
, attribute "attr-for-selected" "value"
, on "iron-select" (selectedDecoder |> Decode.map 
Selected)
]
[ paperItem [ value "0" ] [ text "Bold" ]
, paperItem [ value "1" ] [ text "Italic" ]
, paperItem [ value "2" ] [ text "Underline" ]
, paperItem [ value "3" ] [ text "Strikethrough" ]
]
  )
]
]
]


selectedDecoder : Decode.Decoder (Result String Int)
selectedDecoder =
Decode.at [ "detail", "item", "value" ] Decode.string |> Decode.map 
String.toInt 

That is, applying "on" to "iron-select", setting values on the items in the 
list, and then using "at" from Json.Decode to drill down to where the value 
is in the event.

There's no stoppin' us now!

>

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread Peter Damoc
This works for me in both Chrome and Firefox on OS X with
the  'webcomponents-lite.js'

Thanks for solving this.



On Thu, Oct 6, 2016 at 2:11 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Thursday, October 6, 2016 at 12:07:15 PM UTC+1, Rupert Smith wrote:
>>
>> On Thursday, October 6, 2016 at 11:50:01 AM UTC+1, Rupert Smith wrote:
>>>
>>> On Thursday, October 6, 2016 at 11:14:46 AM UTC+1, Peter Damoc wrote:

 Custom elements also work decently when the custom element takes no
 children but if it does, it stops working.

>>>
>>> Rendering of keyed nodes in the vdom is here:
>>>
>>> https://github.com/elm-lang/virtual-dom/blob/master/src/Nati
>>> ve/VirtualDom.js#L382
>>>
>>> I will try attaching a debug break point there and see if that yields
>>> any insights.
>>>
>>
>> Ok, got it working. I needed to add some global config to polymer like
>> this:
>>
>> > >
>> 
>> window.Polymer = {
>> dom: 'shadow',
>> lazyRegister: true
>> };
>> 
>>
>> As described here:
>>
>> https://www.polymer-project.org/1.0/docs/devguide/settings
>>
>> This was just a guess, I have not played around with different values of
>> the settings, e.g., lazyRegister true/false. But at least the child
>> elements are not dissappearing.
>>
>
> I think this will also necessitate using 'webcomponents.js' instead of
> 'webcomponents-lite.js' for browsers other than Chrome, as the former
> includes the shadow dom polyfill. Actually, I am prepared to be surprised
> if this works outside of chrome...
>
> https://www.polymer-project.org/1.0/docs/browsers
>
> --
> 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] Re: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Thursday, October 6, 2016 at 12:07:15 PM UTC+1, Rupert Smith wrote:
>
> On Thursday, October 6, 2016 at 11:50:01 AM UTC+1, Rupert Smith wrote:
>>
>> On Thursday, October 6, 2016 at 11:14:46 AM UTC+1, Peter Damoc wrote:
>>>
>>> Custom elements also work decently when the custom element takes no 
>>> children but if it does, it stops working. 
>>>
>>
>> Rendering of keyed nodes in the vdom is here:
>>
>>
>> https://github.com/elm-lang/virtual-dom/blob/master/src/Native/VirtualDom.js#L382
>>  
>>
>> I will try attaching a debug break point there and see if that yields any 
>> insights.
>>
>
> Ok, got it working. I needed to add some global config to polymer like 
> this:
>
>  src="bower_components/webcomponentsjs/webcomponents-lite.js">
> 
> window.Polymer = {
> dom: 'shadow',
> lazyRegister: true
> };
>  
>
> As described here:
>
> https://www.polymer-project.org/1.0/docs/devguide/settings
>
> This was just a guess, I have not played around with different values of 
> the settings, e.g., lazyRegister true/false. But at least the child 
> elements are not dissappearing.
>

I think this will also necessitate using 'webcomponents.js' instead of 
'webcomponents-lite.js' for browsers other than Chrome, as the former 
includes the shadow dom polyfill. Actually, I am prepared to be surprised 
if this works outside of chrome...

https://www.polymer-project.org/1.0/docs/browsers 

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Thursday, October 6, 2016 at 11:50:01 AM UTC+1, Rupert Smith wrote:
>
> On Thursday, October 6, 2016 at 11:14:46 AM UTC+1, Peter Damoc wrote:
>>
>> Custom elements also work decently when the custom element takes no 
>> children but if it does, it stops working. 
>>
>
> Rendering of keyed nodes in the vdom is here:
>
>
> https://github.com/elm-lang/virtual-dom/blob/master/src/Native/VirtualDom.js#L382
>  
>
> I will try attaching a debug break point there and see if that yields any 
> insights.
>

Ok, got it working. I needed to add some global config to polymer like this:



window.Polymer = {
dom: 'shadow',
lazyRegister: true
};
 

As described here:

https://www.polymer-project.org/1.0/docs/devguide/settings

This was just a guess, I have not played around with different values of 
the settings, e.g., lazyRegister true/false. But at least the child 
elements are not dissappearing.

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Thursday, October 6, 2016 at 11:14:46 AM UTC+1, Peter Damoc wrote:
>
> Custom elements also work decently when the custom element takes no 
> children but if it does, it stops working. 
>

Rendering of keyed nodes in the vdom is here:

https://github.com/elm-lang/virtual-dom/blob/master/src/Native/VirtualDom.js#L382
 

I will try attaching a debug break point there and see if that yields any 
insights.

-- 
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: Teaching children Elm

2016-10-06 Thread Will White
And if someone yelled "Five" I'd say

-- MISSING PATTERNS  
counter.elm


This `case` does not have branches for all possibilities.


36|>case msg of

37|>Increment ->

38|>model + 1

39|>

40|>Decrement ->

41|>model - 1

You need to account for the following values:


Main.Five


Add a branch to cover this pattern!

Or words to that effect.

On Thursday, October 6, 2016 at 11:36:44 AM UTC+1, Will White wrote:
>
> I've been thinking about how I'll give a talk about Elm (at a JS event in 
> Nottingham, UK). To demonstrate Model-Update-View, I think I'll start with 
> the Counter example, but instead of in code, in real life. So I'd say "I'm 
> a counter, I'm on 0. Increment and Decrement me." and end up with a room of 
> people yelling "Up" and "Down" with me going "4! 5! 4! 3!". Then we'll code 
> it.
>
> Just thought your 14-16 yos might find that fun and illustrative.
>
> On Tuesday, October 4, 2016 at 6:33:04 AM UTC+1, Fedor Nezhivoi wrote:
>>
>> Hello folks,
>>
>>
>> Evan, Richard and the whole community as well as Elm language itself do a 
>> great job in teaching community. If you are staying with this community for 
>> a long time, you probably already can notice some improvements in your 
>> understanding of programming, API design, abstractions and etc. How can we 
>> take it even further?
>>
>>
>> Recently I got an opportunity to share some knowledge about functional 
>> programming and programming in general. However target audience are 
>> children (mostly 14-16 y.o.) and I am a little bit stuck. Not only I've 
>> never been a teacher, but with children I expect it to be even harder 
>> because of curse of knowledge. On the other hand trying to teach some 
>> boring basics doesn't feel right, to be interesting it should be kind of 
>> journey.
>>
>>
>> Previously there was some information about courses in USA where children 
>> are thought programming with Elm. So I am kindly ask people who are doing 
>> this to share your experience, tips, tricks and whatever may be helpful. It 
>> would be even better if you can share some actual 
>> content/topics/lessons/exercises. If you know exact person, but they are 
>> not here, please, provide me with contacts.
>>
>>
>> *I am kindly ask you to abstain from discussions and only participate if 
>> you have something concrete.*
>>
>>
>> Have a nice day!
>>
>

-- 
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: Teaching children Elm

2016-10-06 Thread Will White
I've been thinking about how I'll give a talk about Elm (at a JS event in 
Nottingham, UK). To demonstrate Model-Update-View, I think I'll start with 
the Counter example, but instead of in code, in real life. So I'd say "I'm 
a counter, I'm on 0. Increment and Decrement me." and end up with a room of 
people yelling "Up" and "Down" with me going "4! 5! 4! 3!". Then we'll code 
it.

Just thought your 14-16 yos might find that fun and illustrative.

On Tuesday, October 4, 2016 at 6:33:04 AM UTC+1, Fedor Nezhivoi wrote:
>
> Hello folks,
>
>
> Evan, Richard and the whole community as well as Elm language itself do a 
> great job in teaching community. If you are staying with this community for 
> a long time, you probably already can notice some improvements in your 
> understanding of programming, API design, abstractions and etc. How can we 
> take it even further?
>
>
> Recently I got an opportunity to share some knowledge about functional 
> programming and programming in general. However target audience are 
> children (mostly 14-16 y.o.) and I am a little bit stuck. Not only I've 
> never been a teacher, but with children I expect it to be even harder 
> because of curse of knowledge. On the other hand trying to teach some 
> boring basics doesn't feel right, to be interesting it should be kind of 
> journey.
>
>
> Previously there was some information about courses in USA where children 
> are thought programming with Elm. So I am kindly ask people who are doing 
> this to share your experience, tips, tricks and whatever may be helpful. It 
> would be even better if you can share some actual 
> content/topics/lessons/exercises. If you know exact person, but they are 
> not here, please, provide me with contacts.
>
>
> *I am kindly ask you to abstain from discussions and only participate if 
> you have something concrete.*
>
>
> Have a nice day!
>

-- 
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: Integrating Elm with Web Components / Polymer

2016-10-06 Thread Peter Damoc
I would love some insights from the people who have a better understanding
of what might be happening here.

The custom elements interface looks amazing in theory.

Custom elements also work decently when the custom element takes no
children but if it does, it stops working.

I tried it with paper-buttons-group and it is the same story: it shows up
nicely but as soon as you try to interact with it, the children disappear.
There is no error in the console.



On Thu, Oct 6, 2016 at 12:12 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Wednesday, October 5, 2016 at 4:42:04 PM UTC+1, Rupert Smith wrote:
>>
>> So I can get the select box to appear, but as soon as I click on it, it
>> vanishes. Is this where Html.Keyed helps me out somehow? I did try creating
>> the paper-listbox and paper-item nodes as keyed nodes, but it stills
>> dissapears
>>
>
> So I extracted a minimal polymer listbox + elm example out of my style
> guide and put it here:
>
> https://github.com/rupertlssmith/polymer-elm-listbox
>
> The items dissappear when clicked. As far as I can tell from the listbox
> demo, they should get the style class "iron-selected" added to items when
> they are clicked.
>
> I don't really understand what Html.Keyed does, and whether it can help,
> as its documentation is pretty light on detail and explanation of its
> purpose.
>
> If anyone is able to take a look at this minimal and easy to run example,
> would be much appreciated.
>
> At this stage I am thinking it will be easier to just write my own listbox
> on top of elm-mdl - but the purpose of this thread is to explore whether we
> can integrate polymer and elm succesfully.
>
> --
> 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] Re: Functional programming, or why should I use Elm instead of vanilla javaScript?

2016-10-06 Thread Zachary Kessin
I think this is true of compilers in general. There are a number of scheme
compilers that output C code out there, I expect if you took the output of
one of them and looked at it vs hand written C they would look very
different.

Zach
ᐧ

On Thu, Oct 6, 2016 at 12:22 PM, Will White  wrote:

> Have you seen the JS that Elm compiles to? I've attached what Elm TodoMVC
>  compiles to. Here's the one of the
> first functions:
>
> function F2(fun)
> {
>   function wrapper(a) { return function(b) { return fun(a,b); }; }
>   wrapper.arity = 2;
>   wrapper.func = fun;
>   return wrapper;
> }
>
>
> It's JS, but it's not the kind of application code I'd write in JS. My
> point is that Elm application code is really on another level.
>
>
> On Wednesday, October 5, 2016 at 6:50:52 PM UTC+1, Sarkis Arutiunian wrote:
>>
>> Recently I read article about Functional programming, all 5 parts
>> .
>> Yes it's pretty interesting article, written in interesting way. And I
>> really like pattern of 'functional programming', immutability and etc.
>>
>>
>> But there is a question. Where the line between propriety and paranoia?
>>
>>
>> I prefer use native javaScript for everything where I can do it without
>> any libraries. Yes exactly you should use some UI libraries like React and
>> some module bundler like webpack. But I think propriety of using this tools
>> is obvious. It's better to use JSX then use native js to create DOM or it's
>> better to use webpack at least to uglify and optimize your code because
>> some things just impossible to achieve without webpack.
>>
>> And we have absolutely opposite situation with Elm. Yes they have some
>> features to make function a little bit shorter than you'll do it in vanilla
>> javaScript and only in some case. It's not that difference like create
>> nodes with JSX or js.
>>
>>
>> And all this stuff about immutability, can be easily achieved in plain
>> javaScript. Eventually is Elm code will be converted to plain javaScript
>> and not vice versa, so that's mean you can do all that stuff in javaScript
>> but for sure there are some features in javaScript which you can't do in
>> Elm. And using Elm you are limited with one pattern. And what if it's not
>> enough or it's not best solution in some case, what than? For example right
>> now I'm working on new CMS for one of my projects, on React/GraphQL/Nodejs
>> and hybrid storage MongoDb with mySQL. I would like to use this pattern in
>> some cases but I just can't use it everywhere, so that's mean I shouldn't
>> use Elm?
>>
>>
>> Don't think that I'm against to Elm. I just want to see opinion of
>> others. And I want to see that line, between propriety and paranoia.
>>
>>
>> Thanks.
>>
> --
> 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.
>



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


Re: [elm-discuss] Re: Integrating Elm with Web Components / Polymer

2016-10-06 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, October 5, 2016 at 4:42:04 PM UTC+1, Rupert Smith wrote:
>
> So I can get the select box to appear, but as soon as I click on it, it 
> vanishes. Is this where Html.Keyed helps me out somehow? I did try creating 
> the paper-listbox and paper-item nodes as keyed nodes, but it stills 
> dissapears 
>

So I extracted a minimal polymer listbox + elm example out of my style 
guide and put it here:

https://github.com/rupertlssmith/polymer-elm-listbox 

The items dissappear when clicked. As far as I can tell from the listbox 
demo, they should get the style class "iron-selected" added to items when 
they are clicked.

I don't really understand what Html.Keyed does, and whether it can help, as 
its documentation is pretty light on detail and explanation of its purpose.

If anyone is able to take a look at this minimal and easy to run example, 
would be much appreciated.

At this stage I am thinking it will be easier to just write my own listbox 
on top of elm-mdl - but the purpose of this thread is to explore whether we 
can integrate polymer and elm succesfully.

-- 
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] Functional programming, or why should I use Elm instead of vanilla javaScript?

2016-10-06 Thread Wouter In t Velt
This react-conf 2016 video on Elm 
 (which was when I first heard 
of Elm) is a great explanation of the many things which are possible in 
javascript, but not necesserily good.

Javascript is like an irresponsible parent. You can do pretty much whatever 
you like (which is great), but that includes stuff that is really bad for 
your own future and for the rest of the world.

Elm is like a strict parent. It forces you to work in a disciplined way, 
but you (and your users!) will be really thankful later.


-- 
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] Functional programming, or why should I use Elm instead of vanilla javaScript?

2016-10-06 Thread John Orford
Not only your own discipline but your colleagues's and everyone's
discipline all the way down the 'library stack' - as we see every day -
highly improbable.

What's nice about Elm, is the strict 'contract' everyone signs up to and
can enforce themselves

- fun example,

find a bug in your colleague's code? Setup your types properly and you can
'help' or 'nudge' your colleague into the right direction.

On Thu, 6 Oct 2016 at 08:45 Zachary Kessin  wrote:

> *And all this stuff about immutability, can be easily achieved in plain
> javaScript. Eventually is Elm code will be converted to plain javaScript
> and not vice versa, so that's mean you can do all that stuff in javaScript
> but for sure there are some features in javaScript which you can't do in
> Elm. And using Elm you are limited with one pattern. And what if it's not
> enough or it's not best solution in some case, what than? For example right
> now I'm working on new CMS for one of my projects, on React/GraphQL/Nodejs
> and hybrid storage MongoDb with mySQL. I would like to use this pattern in
> some cases but I just can't use it everywhere, so that's mean I shouldn't
> use Elm?*
>
> This is true, there are some things you can do in JavaScript that you
> can't do in Elm, but this is the key point, that is a good thing! By
> definition anything you can do in elm you can do in Javascript. But the
> benefits of elm is that it will not let you do things that are likely to
> cause problems. I have been a web developer for 20+ years now and I can say
> that if someone can find a way to do something stupid in development then
> they will!
>
> Good coding in raw javascript requires a large amount of developer
> discipline, you must be careful all the time. Languages like elm take that
> job from the human and put it in the computer!
>
>
> ᐧ
>
> On Wed, Oct 5, 2016 at 10:27 PM, Duane Johnson 
> wrote:
>
>
> On Wed, Oct 5, 2016 at 11:43 AM, Sarkis Arutiunian 
> wrote:
>
> For example right now I'm working on new CMS for one of my projects, on
> React/GraphQL/Nodejs and hybrid storage MongoDb with mySQL. I would like to
> use this pattern in some cases but I just can't use it everywhere, so
> that's mean I shouldn't use Elm?
>
>
> What are you hoping to do in Elm that you currently can't? Is it the
> server side portion?
>
> There was a post earlier today by Charles Scalfani that piqued my
> interest. He is using an Effect Manager to implement a postgresql database
> access library for server-side Elm:
> https://github.com/panosoft?utf8=%E2%9C%93&query=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.
>
>
>
>
> --
> 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.
>

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