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

2016-07-30 Thread Job van der Zwan
On Thursday, 28 July 2016 20:42:44 UTC+2, John Bugner wrote:
>
> (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)".)
>

Here's how Julia handles this, although it seems to require hand-coding all 
of of the promotion rules:

http://docs.julialang.org/en/release-0.4/devdocs/promote-op/

(understanding this may require a bit of understanding Julia's type system, 
which lets you define your own types down to the bit-level 
, complete with custom 
conversion and promotion rules 
)

Not sure how that might translate to Elm's type system, but I guess using 
custom infix operators will be part of it (except for not allowing 
redefining the built-in ones). Off-topic, but is this really all 
documentation available on infix operators? Because I don't really think 
that's good enough:

http://elm-lang.org/docs/syntax#infix-operators 

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


[elm-discuss] Elm good for graphical apps?

2016-07-30 Thread 'Rupert Smith' via Elm Discuss
New to Elm, hello all. I only heard about Elm because Manning send me 
emails about their MEAP books and the latest one was for 'Elm in Action'.

I noticed that quite a few Elm examples are graphical, the asteroid game, 
or elm-flatris, sketch-n-sketch. Is there something about Elm that makes it 
suited to working with HTML canvas?

I am writing an application that could conveniently be described as like a 
UML modeller. I would like to mix fairly simple graphical elements and text 
and particularly text input fields. Up until now I have been trying out 
Paper.js - which does not support text input fields. Do you think Elm might 
be useful for this type of application?

Thanks for your input.

Rupert

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


[elm-discuss] Elm inspired by ML?

2016-07-30 Thread 'Rupert Smith' via Elm Discuss
Just looking at Elm for the first time, and have not really sunk my teeth 
into it. I notice that its syntax and type system slightly resemble ML, has 
the language ML been an influence on Elm?

Rupert

-- 
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: Elmx

2016-07-30 Thread Rex van der Spuy
Hi,

"Elmx" is just ordinary Elm functions that happen to have exactly the same 
names as HTML tags. 
So, it's 100% first class, if that's what you mean...?
Those functions just take two parameters: a list of attributes and a list 
of child nodes.

http://guide.elm-lang.org/architecture/user_input/buttons.html

Personally, for me, Elm makes makes working with HTML "almost nice" (as 
opposed to "patently horrible", which is what working with plain-vanilla 
HTML is ... and JSX isn't any better.)
So, yeah, it's awesome :)

-- 
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] Elm inspired by ML?

2016-07-30 Thread Janis Voigtländer
Yes. Mainly through the ML "dialect" OCaml. 

> Am 30.07.2016 um 11:39 schrieb 'Rupert Smith' via Elm Discuss 
> :
> 
> Just looking at Elm for the first time, and have not really sunk my teeth 
> into it. I notice that its syntax and type system slightly resemble ML, has 
> the language ML been an influence on Elm?
> 
> Rupert
> -- 
> 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] Elm good for graphical apps?

2016-07-30 Thread Duane Johnson
Welcome, Rupert! Elm started small and has been growing significantly in
the last year. In its initial phase, it focused a lot on the
graphical/canvas oriented possibilities. Many web developers gravitated
toward its innovative ideas and its javascript-community-friendly culture,
however, and Elm's creator has now spent a lot of time (along with many
others) making it better suited to a more general web application
framework. In other words, it isn't just canvas graphics any more, although
you can still do that.

I think you may find a UML modeller would work well with SVG, and Elm also
supports that quite nicely. I think it's still missing a higher-level
library in this area (for instance, I find my SVG code peppered with a lot
of toString calls while converting numbers to SVG attributes) but because
it's implemented in the virtual-dom manner (similar to React) it's very
pleasant to make state changes. See
http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/

On Sat, Jul 30, 2016 at 3:37 AM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> New to Elm, hello all. I only heard about Elm because Manning send me
> emails about their MEAP books and the latest one was for 'Elm in Action'.
>
> I noticed that quite a few Elm examples are graphical, the asteroid game,
> or elm-flatris, sketch-n-sketch. Is there something about Elm that makes it
> suited to working with HTML canvas?
>
> I am writing an application that could conveniently be described as like a
> UML modeller. I would like to mix fairly simple graphical elements and text
> and particularly text input fields. Up until now I have been trying out
> Paper.js - which does not support text input fields. Do you think Elm might
> be useful for this type of application?
>
> Thanks for your input.
>
> Rupert
>
> --
> 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] Elm inspired by ML?

2016-07-30 Thread 'Rupert Smith' via Elm Discuss
Brilliant. When I was a student 20 years ago they made us learn ML and I 
used it for all my coursework, standard ML for my undergrad thesis and 
OCaml for my masters. I think I am going to like Elm a lot.

On Saturday, July 30, 2016 at 3:29:51 PM UTC+1, Janis Voigtländer wrote:
>
> Yes. Mainly through the ML "dialect" OCaml. 
>
> Am 30.07.2016 um 11:39 schrieb 'Rupert Smith' via Elm Discuss <
> elm-d...@googlegroups.com >:
>
> Just looking at Elm for the first time, and have not really sunk my teeth 
> into it. I notice that its syntax and type system slightly resemble ML, has 
> the language ML been an influence on Elm?
>
> Rupert
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elm-discuss...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>

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


Re: [elm-discuss] Elm good for graphical apps?

2016-07-30 Thread 'Rupert Smith' via Elm Discuss
Is SVG good for interactive GUIs though?

On Saturday, July 30, 2016 at 4:12:37 PM UTC+1, Duane Johnson wrote:
>
> Welcome, Rupert! Elm started small and has been growing significantly in 
> the last year. In its initial phase, it focused a lot on the 
> graphical/canvas oriented possibilities. Many web developers gravitated 
> toward its innovative ideas and its javascript-community-friendly culture, 
> however, and Elm's creator has now spent a lot of time (along with many 
> others) making it better suited to a more general web application 
> framework. In other words, it isn't just canvas graphics any more, although 
> you can still do that.
>
> I think you may find a UML modeller would work well with SVG, and Elm also 
> supports that quite nicely. I think it's still missing a higher-level 
> library in this area (for instance, I find my SVG code peppered with a lot 
> of toString calls while converting numbers to SVG attributes) but because 
> it's implemented in the virtual-dom manner (similar to React) it's very 
> pleasant to make state changes. See 
> http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/
>
> On Sat, Jul 30, 2016 at 3:37 AM, 'Rupert Smith' via Elm Discuss <
> elm-d...@googlegroups.com > wrote:
>
>> New to Elm, hello all. I only heard about Elm because Manning send me 
>> emails about their MEAP books and the latest one was for 'Elm in Action'.
>>
>> I noticed that quite a few Elm examples are graphical, the asteroid game, 
>> or elm-flatris, sketch-n-sketch. Is there something about Elm that makes it 
>> suited to working with HTML canvas?
>>
>> I am writing an application that could conveniently be described as like 
>> a UML modeller. I would like to mix fairly simple graphical elements and 
>> text and particularly text input fields. Up until now I have been trying 
>> out Paper.js - which does not support text input fields. Do you think Elm 
>> might be useful for this type of application?
>>
>> Thanks for your input.
>>
>> Rupert
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[elm-discuss] Re: Collecting use cases for File, ArrayBuffer and TypedArrays/DataViews

2016-07-30 Thread Jan Weitz
I would like Binary decoders/encoders as John Watson  mentioned, as well.


- Encoding/Decoding MQTT messages (which itself might contain Protobuf 
messages) [
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718013]
- Encoding/Decoding Protobuf3 binary messages [
https://developers.google.com/protocol-buffers/docs/encoding]

Inspirations for native interfaces (for web or server-side) might be:

- https://github.com/dcodeIO/bytebuffer.js [Native/bytebuffer.js and 
ByteBuffer.elm]
- https://github.com/dcodeIO/long.js
- (https://github.com/dcodeIO/ProtoBuf.js) [Should be regular elm code]
- (https://github.com/google/protobuf/tree/master/js/binary) [Should be 
regular elm code]



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

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


Re: [elm-discuss] Elm inspired by ML?

2016-07-30 Thread Joey Eremondi
I'd say Elm is a mix of ML and Haskell (which is itself ML inspired)

ML:
: for type signatures
:: for cons
Strict evaluation
No typeclasses
(extensible) Records
Let-expressions instead of where statements

Haskell:
no mutable variables
Left to right notation for type constructors ("List a" instead of "a' List")
Naming of lots of std library functions (i.e. Maybe instead of Option)
Lambda notation, other syntax

On Sat, Jul 30, 2016 at 11:55 AM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> Brilliant. When I was a student 20 years ago they made us learn ML and I
> used it for all my coursework, standard ML for my undergrad thesis and
> OCaml for my masters. I think I am going to like Elm a lot.
>
> On Saturday, July 30, 2016 at 3:29:51 PM UTC+1, Janis Voigtländer wrote:
>>
>> Yes. Mainly through the ML "dialect" OCaml.
>>
>> Am 30.07.2016 um 11:39 schrieb 'Rupert Smith' via Elm Discuss <
>> elm-d...@googlegroups.com>:
>>
>> Just looking at Elm for the first time, and have not really sunk my teeth
>> into it. I notice that its syntax and type system slightly resemble ML, has
>> the language ML been an influence on Elm?
>>
>> Rupert
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[elm-discuss] Dot notation for default value fails on compilation

2016-07-30 Thread Austin Baltes
Hi, I'm working on building a scatterPlot module for one of my Elm projects.

This works (assigning Sp.defaultProps into defaultProps)
import ScatterPlot as Sp
defaultProps = Sp.defaultProps
init : (Model, Cmd Msg)
init =
  ( Model
  { defaultProps
  | series =
  [ { x = 0, y = 1000 }
  , { x = 1, y = 800 }
  , { x = 2, y = 700 }
  , { x = 3, y = 630 }
  , { x = 4, y = 590 }
  , { x = 5, y = 530 }
  , { x = 6, y = 500 }
  , { x = 7, y = 480 }
  ]
  , xRange = { lower = 0, upper = 10 }
  , yRange = { lower = 0, upper = 1000 }
  , chartWidth = 400
  , chartHeight = 200
  }
  , Cmd.none
  )


But this throws a compiler error
import ScatterPlot as Sp
init : (Model, Cmd Msg)
init =
  ( Model
  { Sp.defaultProps
  | series =
  [ { x = 0, y = 1000 }
  , { x = 1, y = 800 }
  , { x = 2, y = 700 }
  , { x = 3, y = 630 }
  , { x = 4, y = 590 }
  , { x = 5, y = 530 }
  , { x = 6, y = 500 }
  , { x = 7, y = 480 }
  ]
  , xRange = { lower = 0, upper = 10 }
  , yRange = { lower = 0, upper = 1000 }
  , chartWidth = 400
  , chartHeight = 200
  }
  , Cmd.none
  )

I ran into something unexpected when parsing your code! 23| { 
Sp.defaultProps ^ I am looking for one of the following things: a closing 
bracket '}' a lower case name whitespace

It'd be nice to use Sp.defaultProps to be more succinct and keep the new 
name space clean, but I haven't figured out how to do this yet.

this is my implementation in ScatterPlot.elm
module ScatterPlot exposing (Point, Series, Range, Props, defaultProps, 
scatterPlot)
defaultProps : Props
defaultProps =
  { series = []
  , xRange = { lower = 0, upper = 100 }
  , yRange = { lower = 0, upper = 100 }
  , chartHeight = 100
  , chartWidth = 100
  }

Thanks for any help; just starting in elm and working to get comfortable 
with modularizing code.

-- 
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] Decoding JSON for Lists of Objects With Arbitrary Fields

2016-07-30 Thread Gary Young
Hi guys,

I have a reporting app where actions by the user generate arbitrary lists 
of objects(records) coming back from a JSON store.  I do not know at 
compile time what the fields in the objects(records) will be.  Can Elm do 
this?  How?

Thanks in advance!

-- 
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] Elm good for graphical apps?

2016-07-30 Thread Duane Johnson
On Sat, Jul 30, 2016 at 1:03 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> Is SVG good for interactive GUIs though?


In my experience, SVG is even better for interactive GUIs, unless you have
very dense graphic elements, or your UI is more on the unusual/experimental
side of things and you need full control over every pixel. The reason SVG
is nice to work with is that a built-in concept to SVG is an "object" that
has width and height and properties like stroke width and fill color. This
tends to be really nice to work with because along with these properties
you also have standard events like mouse clicks and that sort of thing that
you can hook in to.

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


Re: [elm-discuss] Decoding JSON for Lists of Objects With Arbitrary Fields

2016-07-30 Thread Duane Johnson
Yes, if you keep the objects in the Json.Encode.Value type, then you can
contain a tree of arbitrary JSON types all the way down.

This helped me understand the above Json.Encode.Value type a little bit
better:

$ elm repl

> import Json.Encode
> Json.Encode.string "hi"
"hi" : Json.Encode.Value
> Json.Encode.list []
{} : Json.Encode.Value
> Json.Encode.list [Json.Encode.string "hi"]
{ 0 = "hi" } : Json.Encode.Value
> Json.Encode.object [("hi", Json.Encode.int 1), ("bye", Json.Encode.list [
Json.Encode.int 1, Json.Encode.int 2])]
{ hi = 1, bye = { 0 = 1, 1 = 2 } } : Json.Encode.Value

So basically, you can keep encoding things as this generic
"Json.Encode.Value" type, and nesting them inside one another. From Elm's
perspective, they're all the same type, so where javascript arrays could
have multiple things in them (e.g. ["one", 2, {3: "four"}]) Elm is ok with
a list of single-type things.


On Sat, Jul 30, 2016 at 3:15 PM, Gary Young  wrote:

> Hi guys,
>
> I have a reporting app where actions by the user generate arbitrary lists
> of objects(records) coming back from a JSON store.  I do not know at
> compile time what the fields in the objects(records) will be.  Can Elm do
> this?  How?
>
> Thanks in advance!
>
> --
> 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] Dot notation for default value fails on compilation

2016-07-30 Thread Janis Voigtländer
Known issue: https://github.com/elm-lang/elm-compiler/issues/635.

Am Samstag, 30. Juli 2016 schrieb Austin Baltes :

> Hi, I'm working on building a scatterPlot module for one of my Elm
> projects.
>
> This works (assigning Sp.defaultProps into defaultProps)
> import ScatterPlot as Sp
> defaultProps = Sp.defaultProps
> init : (Model, Cmd Msg)
> init =
>   ( Model
>   { defaultProps
>   | series =
>   [ { x = 0, y = 1000 }
>   , { x = 1, y = 800 }
>   , { x = 2, y = 700 }
>   , { x = 3, y = 630 }
>   , { x = 4, y = 590 }
>   , { x = 5, y = 530 }
>   , { x = 6, y = 500 }
>   , { x = 7, y = 480 }
>   ]
>   , xRange = { lower = 0, upper = 10 }
>   , yRange = { lower = 0, upper = 1000 }
>   , chartWidth = 400
>   , chartHeight = 200
>   }
>   , Cmd.none
>   )
>
>
> But this throws a compiler error
> import ScatterPlot as Sp
> init : (Model, Cmd Msg)
> init =
>   ( Model
>   { Sp.defaultProps
>   | series =
>   [ { x = 0, y = 1000 }
>   , { x = 1, y = 800 }
>   , { x = 2, y = 700 }
>   , { x = 3, y = 630 }
>   , { x = 4, y = 590 }
>   , { x = 5, y = 530 }
>   , { x = 6, y = 500 }
>   , { x = 7, y = 480 }
>   ]
>   , xRange = { lower = 0, upper = 10 }
>   , yRange = { lower = 0, upper = 1000 }
>   , chartWidth = 400
>   , chartHeight = 200
>   }
>   , Cmd.none
>   )
>
> I ran into something unexpected when parsing your code! 23| {
> Sp.defaultProps ^ I am looking for one of the following things: a closing
> bracket '}' a lower case name whitespace
>
> It'd be nice to use Sp.defaultProps to be more succinct and keep the new
> name space clean, but I haven't figured out how to do this yet.
>
> this is my implementation in ScatterPlot.elm
> module ScatterPlot exposing (Point, Series, Range, Props, defaultProps,
> scatterPlot)
> defaultProps : Props
> defaultProps =
>   { series = []
>   , xRange = { lower = 0, upper = 100 }
>   , yRange = { lower = 0, upper = 100 }
>   , chartHeight = 100
>   , chartWidth = 100
>   }
>
> Thanks for any help; just starting in elm and working to get comfortable
> with modularizing code.
>
> --
> 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] Decoding JSON for Lists of Objects With Arbitrary Fields

2016-07-30 Thread Gary Young
Thanks Duane, but I don't see how your suggestion fixes my problem.

My goal is to manipulate a single string variable, call it "theJson", into 
an Elm list of records so that I can operate on it as I would any other 
list of records in Elm.  

So far I believe this cannot be done because Elm doesn't allow record 
fields to be added at run time.  Previously Elm had the capability of doing 
this, but it was recently removed.  

Is my research accurate?  I have a number of applications where I must do 
this type of thing, and I believe this is a common enough use-case that the 
Elm creators would want to support it.

Thanks!


On Saturday, July 30, 2016 at 4:24:43 PM UTC-5, Duane Johnson wrote:
>
> Yes, if you keep the objects in the Json.Encode.Value type, then you can 
> contain a tree of arbitrary JSON types all the way down.
>
> This helped me understand the above Json.Encode.Value type a little bit 
> better:
>
> $ elm repl
>
> > import Json.Encode
> > Json.Encode.string "hi"
> "hi" : Json.Encode.Value
> > Json.Encode.list []
> {} : Json.Encode.Value
> > Json.Encode.list [Json.Encode.string "hi"]
> { 0 = "hi" } : Json.Encode.Value
> > Json.Encode.object [("hi", Json.Encode.int 1), ("bye", Json.Encode.list 
> [Json.Encode.int 1, Json.Encode.int 2])]
> { hi = 1, bye = { 0 = 1, 1 = 2 } } : Json.Encode.Value
>
> So basically, you can keep encoding things as this generic 
> "Json.Encode.Value" type, and nesting them inside one another. From Elm's 
> perspective, they're all the same type, so where javascript arrays could 
> have multiple things in them (e.g. ["one", 2, {3: "four"}]) Elm is ok with 
> a list of single-type things.
>
>
> On Sat, Jul 30, 2016 at 3:15 PM, Gary Young  > wrote:
>
>> Hi guys,
>>
>> I have a reporting app where actions by the user generate arbitrary lists 
>> of objects(records) coming back from a JSON store.  I do not know at 
>> compile time what the fields in the objects(records) will be.  Can Elm do 
>> this?  How?
>>
>> Thanks in advance!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [elm-discuss] Decoding JSON for Lists of Objects With Arbitrary Fields

2016-07-30 Thread Nick Hollon
Elm has never allowed for arbitrary fields to be added to records at runtime ( 
it used to allow field insertion & deletion, but you still need to know the 
field names at compile time )

Instead of a record, maybe you should represent your data as a dict? This has 
the property you are looking for.

> On Jul 30, 2016, at 5:54 PM, Gary Young  wrote:
> 
> Thanks Duane, but I don't see how your suggestion fixes my problem.
> 
> My goal is to manipulate a single string variable, call it "theJson", into an 
> Elm list of records so that I can operate on it as I would any other list of 
> records in Elm.  
> 
> So far I believe this cannot be done because Elm doesn't allow record fields 
> to be added at run time.  Previously Elm had the capability of doing this, 
> but it was recently removed.  
> 
> Is my research accurate?  I have a number of applications where I must do 
> this type of thing, and I believe this is a common enough use-case that the 
> Elm creators would want to support it.
> 
> Thanks!
> 
> 
>> On Saturday, July 30, 2016 at 4:24:43 PM UTC-5, Duane Johnson wrote:
>> Yes, if you keep the objects in the Json.Encode.Value type, then you can 
>> contain a tree of arbitrary JSON types all the way down.
>> 
>> This helped me understand the above Json.Encode.Value type a little bit 
>> better:
>> 
>> $ elm repl
>> 
>> > import Json.Encode
>> > Json.Encode.string "hi"
>> "hi" : Json.Encode.Value
>> > Json.Encode.list []
>> {} : Json.Encode.Value
>> > Json.Encode.list [Json.Encode.string "hi"]
>> { 0 = "hi" } : Json.Encode.Value
>> > Json.Encode.object [("hi", Json.Encode.int 1), ("bye", Json.Encode.list 
>> > [Json.Encode.int 1, Json.Encode.int 2])]
>> { hi = 1, bye = { 0 = 1, 1 = 2 } } : Json.Encode.Value
>> 
>> So basically, you can keep encoding things as this generic 
>> "Json.Encode.Value" type, and nesting them inside one another. From Elm's 
>> perspective, they're all the same type, so where javascript arrays could 
>> have multiple things in them (e.g. ["one", 2, {3: "four"}]) Elm is ok with a 
>> list of single-type things.
>> 
>> 
>>> On Sat, Jul 30, 2016 at 3:15 PM, Gary Young  wrote:
>>> Hi guys,
>>> 
>>> I have a reporting app where actions by the user generate arbitrary lists 
>>> of objects(records) coming back from a JSON store.  I do not know at 
>>> compile time what the fields in the objects(records) will be.  Can Elm do 
>>> this?  How?
>>> 
>>> Thanks in advance!
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Elm Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to elm-discuss...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: [elm-discuss] Dot notation for default value fails on compilation

2016-07-30 Thread Austin B
Oh nice, okay. thank you.

On Saturday, July 30, 2016 at 2:43:36 PM UTC-7, Janis Voigtländer wrote:
>
> Known issue: https://github.com/elm-lang/elm-compiler/issues/635.
>
> Am Samstag, 30. Juli 2016 schrieb Austin Baltes :
>
>> Hi, I'm working on building a scatterPlot module for one of my Elm 
>> projects.
>>
>> This works (assigning Sp.defaultProps into defaultProps)
>> import ScatterPlot as Sp
>> defaultProps = Sp.defaultProps
>> init : (Model, Cmd Msg)
>> init =
>>   ( Model
>>   { defaultProps
>>   | series =
>>   [ { x = 0, y = 1000 }
>>   , { x = 1, y = 800 }
>>   , { x = 2, y = 700 }
>>   , { x = 3, y = 630 }
>>   , { x = 4, y = 590 }
>>   , { x = 5, y = 530 }
>>   , { x = 6, y = 500 }
>>   , { x = 7, y = 480 }
>>   ]
>>   , xRange = { lower = 0, upper = 10 }
>>   , yRange = { lower = 0, upper = 1000 }
>>   , chartWidth = 400
>>   , chartHeight = 200
>>   }
>>   , Cmd.none
>>   )
>>
>>
>> But this throws a compiler error
>> import ScatterPlot as Sp
>> init : (Model, Cmd Msg)
>> init =
>>   ( Model
>>   { Sp.defaultProps
>>   | series =
>>   [ { x = 0, y = 1000 }
>>   , { x = 1, y = 800 }
>>   , { x = 2, y = 700 }
>>   , { x = 3, y = 630 }
>>   , { x = 4, y = 590 }
>>   , { x = 5, y = 530 }
>>   , { x = 6, y = 500 }
>>   , { x = 7, y = 480 }
>>   ]
>>   , xRange = { lower = 0, upper = 10 }
>>   , yRange = { lower = 0, upper = 1000 }
>>   , chartWidth = 400
>>   , chartHeight = 200
>>   }
>>   , Cmd.none
>>   )
>>
>> I ran into something unexpected when parsing your code! 23| { 
>> Sp.defaultProps ^ I am looking for one of the following things: a 
>> closing bracket '}' a lower case name whitespace
>>
>> It'd be nice to use Sp.defaultProps to be more succinct and keep the new 
>> name space clean, but I haven't figured out how to do this yet.
>>
>> this is my implementation in ScatterPlot.elm
>> module ScatterPlot exposing (Point, Series, Range, Props, defaultProps, 
>> scatterPlot)
>> defaultProps : Props
>> defaultProps =
>>   { series = []
>>   , xRange = { lower = 0, upper = 100 }
>>   , yRange = { lower = 0, upper = 100 }
>>   , chartHeight = 100
>>   , chartWidth = 100
>>   }
>>
>> Thanks for any help; just starting in elm and working to get comfortable 
>> with modularizing code.
>>
>> -- 
>> 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.