Re: [elm-discuss] Compile problem between elm version

2017-11-28 Thread Aaron VonderHaar
Hi! [(Float, Float)] should now become: List (Float, Float) On Nov 28, 2017 8:54 AM, wrote: Hi All :), some years ago I wrote a very simple program to generate binary trees. Now Elm won't compile, complaining on type alias L = [(Float, Float)] Someone can

Re: [elm-discuss] why does this code compile?

2017-11-26 Thread Aaron VonderHaar
I'm assuming you're expecting an error because `sum` and `num` are values that are referred to within their own definition? The rule the compiler currently follows is that referring to yourself is allowed if the reference is inside a lambda. (In this example, the compiler does know whether or

Re: [elm-discuss] Decoding a json property with different types of values

2017-11-17 Thread Aaron VonderHaar
The simplest approach would be to use Json.Decode.oneOf along with Json.Decode.map: dataValueDecoder : Json.Decode.Decoder DataValue dataValueDecoder = Json.Decode.oneOf [ Json.Decode.string |> Json.Decode.map Val , ... decode your KeyType record ... |> Json.Decode.map Key

Re: [elm-discuss] Elm-make failing when path has spaces

2017-11-17 Thread Aaron VonderHaar
Hi! This looks like a bug in the VSCode plugin; elm-make and elm-format can both handle paths with spaces, so I suspect the VSCode plugin is not properly quoting the arguments. Does anyone familiar with the plugin have time to take a look at it? On Nov 17, 2017 7:19 AM, "Thiago Temple"

Re: [elm-discuss] best practices for handling unreachable code, i.e., how to handle situations where runtime assertions would be used in other languages

2017-08-21 Thread Aaron VonderHaar
ot;normal" error message (the one that is normally >> used to tell the user they made a mistake). >> >> I think I just talked myself into thinking that this is the reasonable >> way to do it. But it does make me long for runtime exceptions for those >> errors w

Re: [elm-discuss] best practices for handling unreachable code, i.e., how to handle situations where runtime assertions would be used in other languages

2017-08-20 Thread Aaron VonderHaar
I think there are two common approaches: 1) Deal with the Maybe at a different level. You mentioned having a deep call stack, and not wanting to pass a Maybe Int throughout, so maybe somewhere in the stack it makes sense to give a default value. Even though you know you have a non-empty list,

Re: [elm-discuss] Re: elm-format did something change?

2017-08-15 Thread Aaron VonderHaar
As I get closer to the 1.0 release, I've been trying to figure out how we can still get user feedback for future format changes. So the plan is to have -exp releases that have features that may change or be removed before the next release. I was trying that plan out with 0.7.0-exp to see how it

Re: [elm-discuss] Immutable data design problem

2017-07-25 Thread Aaron VonderHaar
ange. Recalculating the whole thing will probably be performant > enough. But I guess there could be an issue with IDs - if some data gets > loaded from the database and needs to preserve existing IDs, I can't just > generate new IDs for the whole set. I'll figure out that problem

Re: [elm-discuss] Immutable data design problem

2017-07-23 Thread Aaron VonderHaar
I'm not sure I understand all the details of your domain model, but it seems like the notable point is that accounts are created implicitly as assessment events occur, and you'd like to be able to, given an assessment event, get the related accounts? I'd probably start with making a module (maybe

Re: [elm-discuss] Re: Why is the signature of 'program.subs' 'model -> Sub msg' ?

2017-07-17 Thread Aaron VonderHaar
Another example is a package like WebSocket, where the package will open a network connection while you are subscribed and close it when you stop subscribing. On Jul 17, 2017 7:19 AM, "Marek Fajkus" wrote: Sometimes you don't need subscriptions if you're in some state. For

Re: [elm-discuss] elm-format seems... problematic

2017-07-05 Thread Aaron VonderHaar
In the case of doc comments `{-| -}`, the way elm-format moves them is indicative of how elm-make and elm-package interpret them, so if elm-format is moving those, you probably had them in the wrong place. For other comments, there is unfortunately ambiguity in Elm's syntax about what any given

Re: [elm-discuss] How to properly test a module?

2017-06-17 Thread Aaron VonderHaar
Probably the best starting point are the docs for elm-community/elm-test if you haven't seen them already: http://package.elm-lang.org/packages/elm-community/elm-test/latest On Sat, Jun 17, 2017 at 7:32 AM, John Bugner wrote: > So, I made a module!:

Re: [elm-discuss] Re: Adding CSS produced by a view function to the document's

2017-06-08 Thread Aaron VonderHaar
I experimented with some ways to have view functions that return both Html and the necessary styles. I found I could make it work, but I ultimately abandoned the idea because of a fundamental problem: view model = if model.showWidget then Widget.view model.widgetData else

Re: [elm-discuss] Unexpected Time.every drift over time

2017-06-04 Thread Aaron VonderHaar
Time.every relies on javascript's setInterval. Do you see the same drift in Safari/node using setInterval? If you need more accurate timing, it's possible to attempt that now using a combination of Time.now and Process.sleep (every time you get a message, check the timestamp and calculate how

Re: [elm-discuss] Idris holes - Thoughts for Elm?

2017-05-22 Thread Aaron VonderHaar
If you haven't seen it already, https://atom.io/packages/elmjutsu has support for creating case statement scaffolds (search the README for "Insert case/of") On Mon, May 22, 2017 at 10:06 PM, Zachary Kessin wrote: > totally agree, it would also make it easier to have your

Re: [elm-discuss] Idris holes - Thoughts for Elm?

2017-05-22 Thread Aaron VonderHaar
I think you could easily experiment with this style of development without any syntax changes: ``` module Holes exposing (hole) hole : String -> a hole name = Debug.crash ("unfilled hole: " ++ name) ``` and replace elm-make with: ``` #!/bin/bash set -ex elm-make "$@" echo "Type Checking

Re: [elm-discuss] Implementing a protocol on top of WebSocket: should I build a effect module ?

2017-05-16 Thread Aaron VonderHaar
Level module is interesting for send batches, but my > > main issue is how to associate a custom message translator to each > > subscription in a global protocol state. > > Plus the WebSocket module provides very useful behavior I would prefer > not to reimplement. > >

Re: [elm-discuss] Implementing a protocol on top of WebSocket: should I build a effect module ?

2017-05-16 Thread Aaron VonderHaar
Hi, I haven't played much with WebSockets, but I have been building a protocol on top of HTTP. I haven't yet run into an issue that made me think to try an effects module. Instead of having custom subscriptions, my package has an `update` function that takes any msgs resulting from its commands

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

2017-04-03 Thread Aaron VonderHaar
Hi! The first thing I'd check is whether your view or update functions end up doing O(n) operations (like iteration) with the large list. (Perhaps searching through it for some reason to do validation as the form changes? If that's the problem, then you'll want to consider alternate data

Re: [elm-discuss] Flags vs Ports

2017-04-03 Thread Aaron VonderHaar
Ahoy! :) Yes, everything you've said is correct, including avoiding unnecessary maybes. On Sun, Apr 2, 2017 at 11:41 PM, Richard Wood wrote: > Sounds like some nautical adventure! > > When is it appropriate to bring in data through flags vs through using > ports. > At the

Re: [elm-discuss] 'Native' -> 'Kernel': a msgpack example

2017-03-23 Thread Aaron VonderHaar
Thanks for sharing your impressions. Is there a particular question you're hoping to have answered or a proposed or attempted solution that you'd like to discuss? On Thu, Mar 23, 2017 at 1:15 PM, Simon wrote: > On elm-dev I get the impression that bigger barriers are

Re: [elm-discuss] Is it possible to create a circular reference in Elm?

2017-03-16 Thread Aaron VonderHaar
Note, however, that it is not difficult to implement the following, even without circular references: ``` reader : Library -> Book -> Maybe Reader borrowing : Library -> Reader -> List Book checkOut : Reader -> Book -> Library -> Maybe Library checkIn : Reader -> Book -> Library -> Library ```

Re: [elm-discuss] JSON decode/encode fails on the object with key name starting as a number :(

2016-12-29 Thread Aaron VonderHaar
The name of the field in the Elm record does not need to match the name of the field in the JSON, so you can fix the code generated by json-to-elm by renaming the "1Sa" field in the type alias to something that doesn't start with a number. On Thu, Dec 29, 2016 at 8:28 PM, Jaroslaw Zabiello

Re: [elm-discuss] Tuple indexing?

2016-12-27 Thread Aaron VonderHaar
are unimportant. > > On Tuesday, December 27, 2016 at 1:08:03 PM UTC-5, Aaron VonderHaar wrote: >> >> One reason `first` and `second` are only defined for 2-tuples is that >> it's usually a better choice to use records if you have more than a couple >> fields. >> >> I

Re: [elm-discuss] Tuple indexing?

2016-12-27 Thread Aaron VonderHaar
One reason `first` and `second` are only defined for 2-tuples is that it's usually a better choice to use records if you have more than a couple fields. If defining a record type alias and giving names to you're fields doesn't work for your situation, can you give more details about why? On Dec

Re: [elm-discuss] How can I iterate over the list of records to apply a function

2016-12-26 Thread Aaron VonderHaar
Hello, the answer depends a bit on what you intend to do with the Bools after you have them... But if, as you describe, you just want to end up with a List of Bools, then List.map (\r -> r.age >= 21) yourRecords But I expect you may also be interested in one of `List.filter`, `List.all`, or

Re: [elm-discuss] Re: Transducer.transduceList, stateful transducers, and foldr

2016-12-18 Thread Aaron VonderHaar
Hello, I'm the author of elm-transducers, and I will note that I haven't used in an actual project, nor have I heard of many people using it. So it's certainly possible that there could be bug in the elm-transducers package. The code you mentioned: transduceList = transduce List.foldr (::)

Re: [elm-discuss] Re: fold function argument order

2016-12-08 Thread Aaron VonderHaar
What's confusing here is how currying works with infix operators. It's idiomatic in Elm to have your accumulator be the last argument, and, for instance, if you were writing your own data type, you would want to write your functions so that they can be chained together easily: myMatrix

[elm-discuss] Getting functions out of the model

2016-10-13 Thread Aaron VonderHaar
As mentioned in some recent threads [1] [2], easing functions for animations have been an example of where functions in the model are currently used. An alternative approach is to use a union type to indicate the easing, but a suggested shortcoming of that approach is that there would then be no

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

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,

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

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

Re: [elm-discuss] Does CSS model the right problem?

2016-09-25 Thread Aaron VonderHaar
You may be interested in looking at Auto Layout for Mac and iOS apps. https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/index.html It uses a system of linear equations to solve the defined layout constraints. On Sep 25, 2016 4:47 PM, "Duane Johnson"

Re: [elm-discuss] Elm and contenteditable

2016-08-30 Thread Aaron VonderHaar
Peter, I'd guess the decoder in your onChange is failing, causing the event not to send a Msg. The decoder is going to get an event object, not a DOM node, which is probably why decoding an "innerHTML" property is failing. (Did your comment mean that your event handler does work for

Re: [elm-discuss] Re: Dependency problems building elm-make from source

2016-08-15 Thread Aaron VonderHaar
(also, cabal version 1.22) On Mon, Aug 15, 2016 at 10:27 PM, Aaron VonderHaar <gruen0aer...@gmail.com> wrote: > I believe you will need to use ghc 7, not ghc 8. (elm-compiler's CI uses > ghc-7.10.1, but ghc-7.10.3 should probably work fine as well.) > > On Sun, Aug 14, 201

Re: [elm-discuss] Re: Dependency problems building elm-make from source

2016-08-15 Thread Aaron VonderHaar
I believe you will need to use ghc 7, not ghc 8. (elm-compiler's CI uses ghc-7.10.1, but ghc-7.10.3 should probably work fine as well.) On Sun, Aug 14, 2016 at 8:04 PM, Kofi Gumbs wrote: > I came across this thread >

Re: [elm-discuss] Re: Record update syntax

2016-08-15 Thread Aaron VonderHaar
Can you give more details about an example of where doing nested record updates is useful? When I've run into nested records in real projects, usually it's a better choice to remove the nested update. Here are two ways to do that: 1) flatten the record This is appropriate when a single module

Re: [elm-discuss] How do I organize "inheritance" between my data types?

2016-07-17 Thread Aaron VonderHaar
and functions that operate on child classes, and > it's all type safe? > > On Sunday, July 17, 2016 at 7:13:33 PM UTC-5, Aaron VonderHaar wrote: >> >> Can you give more details about what you are trying to do that requires a >> Person type that can be either an employee o

Re: [elm-discuss] How do I organize "inheritance" between my data types?

2016-07-17 Thread Aaron VonderHaar
Can you give more details about what you are trying to do that requires a Person type that can be either an employee or a customer? As you noted, `nameAndDepartment` would only apply to Employees, so why do you need to use it on Customers? Can you simply deal with employees and customers

Re: [elm-discuss] Markdown library

2016-07-15 Thread Aaron VonderHaar
Did you try deleting your `elm-stuff` directory and building again? On Wed, Jul 13, 2016 at 9:07 AM, Esteban Manchado Velázquez < emanch...@gmail.com> wrote: > Hi, > > I'm trying to use the Markdown library (evancz/elm-markdown) and I cannot > seem to be able to make it work. I ran: > >

Re: [elm-discuss] Newbie question: having trouble using the Focus library

2016-06-19 Thread Aaron VonderHaar
To do this without focus, you’d write something like: updateCanvas : (Canvas -> Canvas) -> Model -> Model updateCanvas fn model = { model | canvas = fn model.canvas } updateScale : (Int -> Int) -> Canvas -> Canvas -- probably put this in Canvas module updateScale fn canvas = { canvas |