[elm-discuss] Testing at @elmconf

2017-09-22 Thread Brian Marick
I’m a big fan of a roughly tabular test format that uses elm-test as building blocks. For example: describe "minutes" [ rejects "a+" "the usual non-numeric values are rejected" , rejects "5.3""rejects floats" , when "59" (Just 59) "upper boundary"

[elm-discuss] destructuring two of the same record

2017-05-30 Thread Brian Marick
Suppose I have a function of this type: friendlyName2 : { whole | id : Int, name : String } -> { whole | id : Int, name : String } -> String Is there a way I can destructure both of those arguments at once? Something that lets me do this: friendlyName2 {name,

[elm-discuss] Cmd.map

2017-03-28 Thread Brian Marick
I’m having trouble thinking of a scenario in which you’d use `Cmd.map`. Is it for a case where you create a `Cmd a` where `a` is something different than the usual `Msg`, then transform it into a `Msg`? (When would you do such a thing?) Or for a case where you want to change the `Msg`

Re: [elm-discuss] Request for idioms / announcement of a possible book

2017-03-15 Thread Brian Marick
I don’t quite understand what you’re saying. Do you have examples of how I might go astray? Or how I’ve already gone astray in the available chapter on Maybe? https://leanpub.com/outsidefp (Part of my confusion is that it seems to me that maybe-is-a-data-structure is the way most programmers

Re: [elm-discuss] Request for idioms / announcement of a possible book

2017-03-14 Thread Brian Marick
> On Mar 13, 2017, at 6:07 PM, 'Rupert Smith' via Elm Discuss > wrote: > Makes sense for Maybe to have its own chapter. Possible also discuss Result > in the same chapter? as they both are ways of defining computations that may > fail. `Result` will be in the

[elm-discuss] Request for idioms / announcement of a possible book

2017-03-10 Thread Brian Marick
I’m four chapters into a book that covers Elm, Purescript, and possibly Idris. It’s to be a book with several significant differences from the usual introduction to a statically typed FP language. One is that I’d like to include lots of idioms and patterns (in the original sense, not the “code

Re: [elm-discuss] Designing with sum and product types

2017-02-23 Thread Brian Marick
> 2. Figure out a state diagram describing the behavior of your UI. I find this > is tending to align very well with one state for each element of the UI that > can change. For example, something shown or hidden, or something shown in one > state or another. Turn the state diagram into a Type -

[elm-discuss] Designing with sum and product types

2017-02-22 Thread Brian Marick
I’m comfortable with sum and product types by themselves, but I flounder when trying to combine them. Should I model the problem as a sum type inside a record? as records in a sum type? I’ve written up a post on how I got backed into a non-type-driven approach:

[elm-discuss] elm-lang/http and evancz/elm-http

2017-01-30 Thread Brian Marick
I’m confused by the relationship between these two libraries. They seem to overlap in functionality, but only the latter has `url` (http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#url ) which seems pretty

[elm-discuss] Disambiguating module and record access

2017-01-12 Thread Brian Marick
Short: I am getting this error when `model_page` is a record inside module `Animals.Model` > Cannot find variable `Model.model_page.set`. > > 13| model |> Model.model_page.set (Page.fromLocation location) |> noCmd > ^^ > No module called

Re: [elm-discuss] Re: pattern match sum type inside a record inside a Maybe

2017-01-11 Thread Brian Marick
> On Jan 11, 2017, at 1:48 PM, Max Goldstein wrote: > > What about: > > case Dict.get id model.displayables |> Maybe.map .view of You are awesome. For the record, here’s the expanded code: > case Dict.get id model.displayables |> Maybe.map .view of >

[elm-discuss] pattern match sum type inside a record inside a Maybe

2017-01-11 Thread Brian Marick
I have these types: > type Affordance > = Writable Form > | Viewable Animal > > type alias Displayed = > { view : Affordance > , animalFlash : AnimalFlash > } … stored inside a Dict. So when I try to get what is the only possible case (a Writable form), I have a nested structure.

Re: [elm-discuss] Making enter/return in text input have same effect as button

2016-12-04 Thread Brian Marick
[ text "Add" ] ]) > On Dec 4, 2016, at 4:54 AM, Matthew Bray <mattjb...@gmail.com> wrote: > > Take a look at onEnter from elm-todomvc: > > https://github.com/evancz/elm-todomvc/blob/master/Todo.elm#L237 > <https://github.com/evancz/elm-todomvc/blob/m

[elm-discuss] Making enter/return in text input have same effect as button

2016-12-03 Thread Brian Marick
(Disclaimer: I didn’t come to Elm knowing Javascript.) Anyone know of a source for code that sends a message when the user presses enter in a particular text input field? I could write the code - eventually - but it looks to be awfully fiddly and something that a zillion people must have done

Re: [elm-discuss] Can Javascript to start Elm app be attached per page?

2016-11-21 Thread Brian Marick
;).whateverApp.embed(blah);`, thus the individual > pages determine what they call, not a lot of checks in the javascript. :-) > > > On Sunday, November 20, 2016 at 4:31:15 PM UTC-7, Brian Marick wrote: > Note: newbie to Javascript and frontend in general. > > TL/DR: I would

[elm-discuss] highlight.js and elm code

2016-11-21 Thread Brian Marick
I recently installed highlight.js (http://highlightjs.readthedocs.io ) on my blog. It’s supposed to understand Elm code, but the results are not appealing: Given the same thing happens with Haskell code, I suspect I’m doing something wrong. Any advice or

[elm-discuss] Can Javascript to start Elm app be attached per page?

2016-11-20 Thread Brian Marick
Note: newbie to Javascript and frontend in general. TL/DR: I would like to see an example of the Best Way to (1) have N urls invoke N single-page Elm apps, and (2) pass each of them url-specific flags (to be received by `Html.App.programWithFlags`). - The Elixir/Phoenix book [1]

Re: [elm-discuss] Uri encoding (Implementing /Programming Phoenix/ with Elm web sockets)

2016-11-07 Thread Brian Marick
Should anyone be interested, I wrote up how to use Elm websockets in a way that matches the exposition in /Programming Phoenix/: http://stackoverflow.com/questions/40475348/how-do-i-pass-connection-time-websocket-parameters-to-phoenix-from-elm > On Nov 6, 2016, at 7:09 PM, Brian Marick &

Re: [elm-discuss] Uri encoding (Implementing /Programming Phoenix/ with Elm web sockets)

2016-11-06 Thread Brian Marick
Sigh. https://twitter.com/jessemcnelis <https://twitter.com/jessemcnelis> pointed me to http://klaftertief.github.io/elm-search/?q=uriencode <http://klaftertief.github.io/elm-search/?q=uriencode> - which works just fine. Sorry for the inconvenience. > On Nov 6, 2016, at 6:23 P

[elm-discuss] Uri encoding (Implementing /Programming Phoenix/ with Elm web sockets)

2016-11-06 Thread Brian Marick
TL/DR: What library do I use to convert `…##...=` into `...%23%...%3D` in order to communicate with Elixir Phoenix via `ws://localhost:4000/socket/websocket?auth_token=...%23%...%3D` ? --- In the /Programming Phoenix/ book https://pragprog.com/book/phoenix/programming-phoenix

Re: [elm-discuss] How to write function that updates arbitrary element of a record

2016-11-01 Thread Brian Marick
> On Oct 23, 2016, at 9:30 PM, Leroy Campbell wrote: > > I think I have something close to what you're looking for, but my solution > makes me wonder, why store text in your model rather than the parsed > float/int values? It seems like you want the parsed values for a

Re: [elm-discuss] Proposal: rename foldl til foldLeft and foldr to foldRight

2016-10-24 Thread Brian Marick
> On Oct 20, 2016, at 9:12 AM, Robin Heggelund Hansen > wrote: > > In Elm 0.18, primes are being removed as valid characters in a > variable/function name. That’s unfortunate. Non-alphabetical characters can be really useful for signaling intent. For example, an

Re: [elm-discuss] Looking for subcomponent example to learn from

2016-10-23 Thread Brian Marick
> On Oct 22, 2016, at 7:56 PM, Nick H wrote: > > Which of these elements can fire events? Is the text at the bottom the only > place where the user can interact? > > If so, then the graphical elements up top can just be functions that take > whatever data is needed

[elm-discuss] Looking for subcomponent example to learn from

2016-10-22 Thread Brian Marick
My app currently has three logically/visually distinct components: The IV drip apparatus (upper left) is something that will be used in more than one page. I’ve been trying to find a way to make it a component that I can reuse, and I’ve been having a good deal of trouble (mostly, I’m

Re: [elm-discuss] How to write function that updates arbitrary element of a record

2016-10-19 Thread Brian Marick
I see I left out a required argument from what I want, which leads me to this: update : Msg -> Model -> Model update msg model = case msg of ChangedDripText string -> updateWhen model isValidFloatString dripText string ChangedHoursText string ->

[elm-discuss] How to write function that updates arbitrary element of a record

2016-10-19 Thread Brian Marick
I have a model that looks like this: type alias Model = { ... , dripText : String , simulationHoursText : String , simulationMinutesText : String ... } Those strings each correspond to a text field containing floating point numbers. The whole thing looks

Re: [elm-discuss] How to use elm-style-animation to make smoothly moving clock hand

2016-09-26 Thread Brian Marick
Thanks all. With help from Matthew Griffith, I have a spinning clock that works. https://github.com/marick/eecrit/tree/crude-spinning/web/elm/IV/Clock The key bits are: * You have to include a “not rotating” property to start with: hourHandStartsAt hour = [ Animation.rotate

[elm-discuss] How to use elm-style-animation to make smoothly moving clock hand

2016-09-25 Thread Brian Marick
As a front end newbie, I was pleased I could make a clock hand with an arrow using a marker https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker That allows me a pretty(ish) clock hand that automagically has the arrowhead appropriately rotated to match the orientation of the line.

[elm-discuss] Confused by error (inline function, >, tagged type)

2016-09-24 Thread Brian Marick
I’m trying to dutifully use tagged types instead of, say, `Float`: type DropsPerSecond = DropsPerSecond Float It turns out I want to know which of two `DropsPerSecond` is larger. Which suggests this: (>) : DropsPerSecond -> DropsPerSecond -> Bool (>) (DropsPerSecond left) (DropsPerSecond

Re: [elm-discuss] Structuring a simple App

2016-09-22 Thread Brian Marick
Perhaps the idiomatic way is just forwarding, as in this from https://medium.com/@_rchaves_/structured-todomvc-example-with-elm-a68d87cd38da#.prhqa9c5n type Msg = NoOp | MsgForComponent1 Component1.Msg | MsgForComponent2 Component2.Msg -- You received this message because you are

Re: [elm-discuss] Re: Post mortem for my first attempt at using Elm in a real app.

2016-09-20 Thread Brian Marick
> On Sep 20, 2016, at 3:46 PM, Peter Damoc wrote: > > As Richard pointed out, Elm is a great choice when the team is already > comfortable with web-dev. > I am a beginner in this field. I’m a front-end beginner too. I wonder how many of us there are, and how we might help

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

2016-09-20 Thread Brian Marick
> On Sep 20, 2016, at 3:21 AM, Richard Feldman > wrote: > > > If nothing is wrong with Web Components, why not use them? > > There are a ton of them > you > could use right now, for MDL in

[elm-discuss] Multiple uses of `Elm.Xyzzy.embed` in a Phoenix app

2016-07-29 Thread Brian Marick
(A Phoenix newbie here, and an *extreme* Elm newbie.) There are several Elm + Phoenix examples out there (though most of them for 0.16). However, I haven't found any that should more than one use of `embed`. Just to get started, I'm trying to embed Elm on two pages. On one page, it's just