[elm-discuss] Re: On Intl/CLDR

2017-09-11 Thread Ian Mackenzie
Exposing window.Intl directly also ties Elm more tightly to the browser/JavaScript environment, which Evan mentioned in that second linked thread that he is trying to avoid: Elm is designed to be 100% independent of JS. It happens to compile to JS > now because that was the right thing to do,

Re: [elm-discuss] Strange compiler error - cannot find a field that is obviously there.

2017-09-11 Thread Ian Mackenzie
Have you added type annotations to all top-level functions/values? My first guess would be some sort of type inference issue that's propagating across files, which can usually be narrowed down by explicitly annotating top-level stuff so that any discrepancies are caught as soon as possible. On

[elm-discuss] Re: Json file size

2017-08-13 Thread Ian Mackenzie
I suspect there will be a way of making this work without dropping into JS. It looks like you're hitting some sort of very deep recursion which is causing a stack overflow - try seeing if you can isolate which of your function calls is triggering the stack overflow, and see if you can change

[elm-discuss] Discovering Elm packages

2017-08-09 Thread Ian Mackenzie
This is great! Already discovered a few interesting packages I didn't know about. Twitter feed followed =) -- 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

Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Ian Mackenzie
I think I would opt for the very literal type Bla = A Int | B Int type BlaConstructor = AConstructor | BConstructor blaConstructor : Bla -> BlaConstructor blaConstructor bla = case bla of A _ -> AConstructor B _ -> BConstructor

[elm-discuss] Re: Linear algebra for 2d geometry?

2017-05-11 Thread Ian Mackenzie
On Tuesday, 9 May 2017 05:25:11 UTC-4, Rupert Smith wrote: > > Thanks for this explanation. Also, I did say in my OP that performance was > not such an important issue for me, as I am only rendering a relatively > static diagram that does not have a huge number of elements in it. I should >

[elm-discuss] Re: Linear algebra for 2d geometry?

2017-05-08 Thread Ian Mackenzie
ay 7, 2017 at 10:02:43 PM UTC+1, Rupert Smith wrote: >> >> On Friday, May 5, 2017 at 7:55:22 PM UTC+1, Ian Mackenzie wrote: >>> >>> So, nice library with lots of features, missed chance to work with a >>>> better abstraction. >>>> >>

[elm-discuss] Re: Linear algebra for 2d geometry?

2017-05-05 Thread Ian Mackenzie
On Friday, 5 May 2017 03:59:48 UTC-4, Rupert Smith wrote: > > On Thursday, May 4, 2017 at 5:53:36 PM UTC+1, Matthieu Pizenberg wrote: >> >> I definitely recommend looking at https://github.com/opensolid/geometry >> (with it's svg counterpart : https://github.com/opensolid/svg). >> I've been using

[elm-discuss] Re: Linear algebra for 2d geometry?

2017-05-05 Thread Ian Mackenzie
On Thursday, 4 May 2017 16:15:38 UTC-4, Rupert Smith wrote: > > I also notice that opensolid/svg is a small library. Would not be hard to > re-implement it over elm-community/typed-svg and remove all those > 'toString's. > True - although when I initially wrote opensolid/svg, typed-svg didn't

[elm-discuss] Re: view function to call other view function with different Msg type

2017-04-23 Thread Ian Mackenzie
Shouldn't that be Html.map, not Html.Attributes.map? itemView returns a Html msg, not an Html.Attribute msg... On Saturday, 22 April 2017 21:53:47 UTC-4, Erik Lott wrote: > > view : Model -> Html Msg > view model = > div [] > (model.items > |> List.map itemView >

[elm-discuss] Re: Elm-reactor and static files (images & videos)

2017-04-23 Thread Ian Mackenzie
You should be able to use the debugger outside of elm-reactor if you compile with the --debug flag, for example elm make --debug Main.elm --output main.js You should then be able to use whatever you want to serve the HTML/JS and you'll still get the debug overlay. On Saturday, 22 April 2017

[elm-discuss] Re: Is there a way to get a compile-time error when a field is added to a record type but its corresponding JSON encoder is not?

2017-04-07 Thread Ian Mackenzie
ng will fail). Not to mention that the test will also catch other silly errors like Encode.object [ ( "firstName", Encode.string person.firstName ), ( "lastName", Encode.string person.firstName ) ]. On Friday, 7 April 2017 10:24:23 UTC-4, Ian Mackenzie wrote: > >

[elm-discuss] Re: Is there a way to get a compile-time error when a field is added to a record type but its corresponding JSON encoder is not?

2017-04-07 Thread Ian Mackenzie
You could change the signature instead of the definition: accountToJson : { id : Int, name : String } -> Json.Encode.Value accountToJson act = Json.Encode.object [ ("id", Json.Encode.int act.id) , ("name", Json.Encode.string act.name) ] For example, https://ellie-app.com/RcvWmTyWFga1/0

[elm-discuss] Re: Noticeable lag when working with a model that contains large dataset

2017-04-03 Thread Ian Mackenzie
Is the issue specific to when running in debug mode (when using Elm Reactor or compiling with --debug), by any chance? I recently encountered an issue where the debugger will scan through the entire model after every update, which is quite slow if there are large data structures in the model. I

Re: [elm-discuss] Linear algebra (matrix, vectors, ...) in the context of image processing

2017-03-05 Thread Ian Mackenzie
I also wonder how memory efficient a pure Elm solution could be, as currently there's no support for binary or packed data representation. That alone might argue for keeping the image data itself on the JavaScript side where you (or the libraries you use) can pull all sorts of tricks with typed

[elm-discuss] Linear algebra (matrix, vectors, ...) in the context of image processing

2017-03-03 Thread Ian Mackenzie
For your second question, I know there's work being done currently on supporting the Canvas API in Elm (https://github.com/elm-community/canvas), which may be more appropriate for visualizing bitmap data than SVG, but it's still very experimental. -- You received this message because you are

Re: [elm-discuss] ANN: opensolid/geometry, a comprehensive 2D/3D geometry package for Elm

2017-02-02 Thread Ian Mackenzie
wrote: > > Nice work! I hope to use this in some of my projects (like the HCCB > package <http://package.elm-lang.org/packages/canadaduane/elm-hccb/latest> > I just released perhaps...) > > On Wed, Feb 1, 2017 at 10:31 AM, Ian Mackenzie <ian.e.m...@gmail.com > >

[elm-discuss] ANN: opensolid/geometry, a comprehensive 2D/3D geometry package for Elm

2017-02-01 Thread Ian Mackenzie
Just posted this to Reddit, but thought I should mention it here as well: http://package.elm-lang.org/packages/opensolid/geometry/latest I'd love to get feedback, and I'm happy to answer any questions! -- You received this message because you are subscribed to the Google Groups "Elm Discuss"

[elm-discuss] Guidance for using "type alias" vs. single-constructor union types

2017-01-16 Thread Ian Mackenzie
I agree with the point about adding helper functions for your data type so you can treat it as opaque in most places. For the rest, though, you can also use the slightly obscure 'as' syntax 'foo ((Foo s) as f) = ...' which allows you to use both 's' and 'f' in your function body (with the

[elm-discuss] Re: Why is "port" forbidden as field name inside record?

2016-12-15 Thread Ian Mackenzie
Well, it certainly seems easier to make a robust parser if keywords are not context-dependent. Yes, perhaps you could tell that { port = "foo" } is a record with a 'port' field, but what about port = "foo"? Is that a record missing its opening and closing braces, or a messed-up declaration of

Re: [elm-discuss] Why is "port" forbidden as field name inside record?

2016-12-15 Thread Ian Mackenzie
You should also be able to switch to ports based on Json.Encode.Value, which gets passed through ports directly as JSON. You'll have to write your own encoders and decoders but you should then be able to use arbitrary field names (since you'll end up specifying them as string literals in your

[elm-discuss] Probably a *very* basic question ...

2016-11-06 Thread Ian Mackenzie
Is the button inside a that is causing it to trigger a form submission when clicked? -- 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] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-25 Thread Ian Mackenzie
I've been slowly working on a small library to make working with the basic input widgets like more pleasant to work with - I'd be interested to see what you think. The implementation

Re: [elm-discuss] Elm, Objects and Components

2016-09-19 Thread Ian Mackenzie
Peter, you may be interested in (and I'd appreciate your feedback on) a little library I've been working on for composable input widgets: https://github.com/kintail/input-widget It seemed to me that in many cases of 'little bits of local state', the widget in question is an input widget of

[elm-discuss] Re: Announcing elm-test 2.1.0!

2016-09-06 Thread Ian Mackenzie
Awesome work! Just updated my test code - mapN and constant are great, and the new auto-shrinking works beautifully. (I just deliberately re-introduced a bug temporarily to try it out and sure enough elm-test found three independent, minimal failure cases.) With 2.0.1 I encountered some stack

[elm-discuss] Re: Remove ways of importing except `import exposing (..)`?

2016-08-18 Thread Ian Mackenzie
strategy though. On Friday, 19 August 2016 09:28:56 UTC+10, Ian Mackenzie wrote: > > It seems to me that the issues you are encountering come from two things: > >- Using a mix of qualified and unqualified imports >- Having a function the same name as one in Basics &

[elm-discuss] Re: Remove ways of importing except `import exposing (..)`?

2016-08-18 Thread Ian Mackenzie
It seems to me that the issues you are encountering come from two things: - Using a mix of qualified and unqualified imports - Having a function the same name as one in Basics One solution is to never use qualified imports, but a better solution is to *always *use qualified imports and

[elm-discuss] Re: Design question: using Dict, List with index, or Array (or something I'm not aware of)

2016-08-13 Thread Ian Mackenzie
My initial reaction is also #3. I think it's totally sensible to do a bit of transformation when serializing/deserializing, and more important to optimize your model for its use in view and update. On Friday, 12 August 2016 23:03:34 UTC+10, Robert Walter wrote: > > Hello, > > following

[elm-discuss] Re: What concepts and models did you had to learn in order to be able to write good Elm code?

2016-08-11 Thread Ian Mackenzie
The most important one I keep coming back to is the design principle of rigorously separating functions and data - don't keep functions in your model, etc. In many ways I jumped on Elm just because it felt so immediately *right* and natural, as opposed to "I heard Elm was great but now I have

[elm-discuss] Re: My first Elm

2016-08-09 Thread Ian Mackenzie
Have you looked at the modularity section of the Elm guide? It doesn't yet specifically cover nesting components that have subscriptions, but points you to examples 3 and 4 here

[elm-discuss] Re: about the Keyboard API

2016-08-09 Thread Ian Mackenzie
I really like this version. It's effectively saying that in the same way that most subscriptions/HTML events take map function arguments since you'd otherwise almost always want to map the result yourself (using Html.App.map or Sub.map), the keyboard functions should take a filter-map function

[elm-discuss] Re: Module communication (state machine)

2016-08-08 Thread Ian Mackenzie
I do rather like #2 - it seems to me that you could even have the result of update be either the usual model/command pair *or* a UserId, i.e. replace both return values, not just the second one. Something like: type State = Active ( Model, Cmd Msg ) | Finished UserId update : Msg ->

[elm-discuss] Re: elm-format vs gofmt

2016-08-07 Thread Ian Mackenzie
For what it's worth, I had the same initial reaction to all the extra whitespace added in 'let' blocks - that was by far the biggest change that elm-format made to my code when I started using it - but I fairly quickly started to like it. Yes, some functions get a lot longer, but that extra

[elm-discuss] elm-format vs gofmt

2016-08-06 Thread Ian Mackenzie
Comment handling can indeed be a bit funny (and elm-format is still under active development, so this may change in the future), but the right solution in this case is probably to use a proper documentation comment for the function instead (one that starts with '{-|' and ends with '-}' - see

Re: [elm-discuss] Re: Should [ 1..5 ] exist?

2016-08-06 Thread Ian Mackenzie
Ah, cool, thanks Jonas! I was worried that the 'loading and indexing' step was querying current data from package.elm-lang.org but I guess you're just periodically downloading and caching that data on your own server instead? I look forward to seeing the final version! -- You received this

[elm-discuss] Sharing test code

2016-08-04 Thread Ian Mackenzie
I've been working on a bunch of related geometric packages and one thing I haven't quite figured out is the best way to structure test code. So far I've been using the fairly common pattern of having a 'test' subdirectory with its own elm-package.json that has "../src" in its source-directories

Re: [elm-discuss] Re: Should [ 1..5 ] exist?

2016-08-04 Thread Ian Mackenzie
Someone actually did implement Hoogle-like search for Elm, and it works pretty well, although using it is probably not kind to the package.elm-lang.org server: http://klaftertief.github.io/package.elm-lang.org/ I'm all for replacing special syntax with List.range or something similar. I'd

[elm-discuss] Re: Modifying the DOM with external JS libraries

2016-07-27 Thread Ian Mackenzie
In this particular case, if you're just using highlight.js to highlight a block of code, you might also be able to use evancz/elm-markdown (http://package.elm-lang.org/packages/evancz/elm-markdown/3.0.0/). You'll still need to load a version of highlight.js in your HTML as described by the

Re: [elm-discuss] Re: undefined: actually I have expected to never face undefined again with elm

2016-07-19 Thread Ian Mackenzie
eas Kobler wrote: > > Thanks a lot! > Bad typo... was not really awake this morning :-/ Now it works as expected! > > 2016-07-19 10:58 GMT+02:00 Ian Mackenzie <ian.e.m...@gmail.com > >: > >> Try 'rule.substitution' instead of 'rule.substitute'. It looks like the

[elm-discuss] Re: Scrolling to bottom of div

2016-07-19 Thread Ian Mackenzie
There isn't yet a pure-Elm way to do it, but there's a bunch of discussion going on right now about adding setScrollTop and similar functions (see https://groups.google.com/forum/#!topic/elm-dev/ThkWudq7SF0). In the meantime the answer is likely 'use ports'. On Tuesday, 19 July 2016 09:27:58

[elm-discuss] Re: undefined: actually I have expected to never face undefined again with elm

2016-07-19 Thread Ian Mackenzie
The issue is likely with the rule = rule line, as Elm sees that as a recursive variable definition which has known bugs ( https://github.com/elm-lang/elm-compiler/issues/873). You should just be able to take that line out, there's no need to re-declare a variable with the same name as an

Re: [elm-discuss] recursively generating a tree

2016-07-12 Thread Ian Mackenzie
Good to know! By the way, is the original code you were working on part of an open-source library, by any chance? I'm working on some 2D/3D geometric libraries for Elm myself, including stuff like bounding boxes and spatial trees much like the one you describe. Might would be worth seeing if

Re: [elm-discuss] Re: Is there a reason Date has no setters?

2016-06-20 Thread Ian Mackenzie
I think one other thing to keep in mind is that Evan has expressed a lot of interest in other (non-JavaScript) compilation targets in the future, so I think he would be very cautious about tying core library functionality too closely to exactly how JavaScript happens to do things. Especially

Re: [elm-discuss] Any open source elm project example for multi-page app?

2016-06-16 Thread Ian Mackenzie
You might want to look at the examples from the 'navigation' package (http://package.elm-lang.org/packages/elm-lang/navigation/1.0.0/) and the related url-parser package (http://package.elm-lang.org/packages/evancz/url-parser/1.0.0/). -- You received this message because you are subscribed to

Re: [elm-discuss] Re: Feature Request: Code Generation/ Macro System

2016-06-16 Thread Ian Mackenzie
Just to throw my two cents in, I'd want to be pretty conservative about any macro/code gen system if there is an official one at all. One of the things I love about Elm is that the restrictive nature of the language makes code very easy to follow and understand, and naturally causes libraries

[elm-discuss] Re: How do you handle module name clashes?

2016-06-10 Thread Ian Mackenzie
I think some sort of guideline for module names would be good, similar to what exists in the Java or .NET worlds - I've been using an 'Organization.Package.Module' scheme for my (yet to be published) code. Easy enough to use 'import as' to shorten things up. On Saturday, 11 June 2016 06:52:10

[elm-discuss] Re: How can I do module level configuration?

2016-05-26 Thread Ian Mackenzie
I think the first solution (context/options argument) is the clearest and simplest. Yes, it's a bit verbose, but: - You can use the 'view' and 'viewWithOptions' pattern where the former calls the latter with a default primary color etc., so you can get convenience if you don't care