Re: [elm-discuss] Re: Randoms as LazyLists

2017-12-13 Thread 'Rupert Smith' via Elm Discuss

On Saturday, December 9, 2017 at 2:13:18 AM UTC, Mark Hamburg wrote:
>
> Functions get garbage collected. Otherwise think what would happen every 
> time you use partial function application or define a function within a let 
> or other nested context. Because those functions (can) capture values, they 
> are new values just as much as a list or record or other data value would 
> be.
>

Is this something that is specific to the way javascript works? In my 
experience partial function applications create a continuation, which is a 
stack frame holding the captured values. Once the function completes the 
stack frame is discarded, so there is no allocation or GC on the heap. Is 
this not how Elm would be implemented on webasm and managing its own memory?

-- 
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: Randoms as LazyLists

2017-12-08 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, December 6, 2017 at 2:38:09 AM UTC, GordonBGood wrote:
>
> Meanwhile the memoized Lazy type library really is needed, else there is 
> no way to implement memoization without custom JavaScript, which is frowned 
> upon.
>

I think you make a good case for keeping it in Gordon. When I started this 
thread, all I really needed is a CIS for random numbers, but I can see that 
true lazy lists have their uses. Is it really worth throwing them out to 
make garbage collection by reference counting only possible if/when Elm is 
ported to web assembly?

-- 
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: Randoms as LazyLists

2017-12-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, December 8, 2017 at 5:55:36 AM UTC, Mark Hamburg wrote:
>
> Functions are also heap allocated objects and reference other objects — 
> e.g., decoders — just like other objects do.
>

But presumably functions do not get garbage collected?

-- 
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: Randoms as LazyLists

2017-12-07 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, December 5, 2017 at 5:16:22 PM UTC, Mark Hamburg wrote:
>
> If you have a recursive JSON structure to decode, then the decoder either 
> needs to refer to itself (a cycle) or it needs to generate a new decoder on 
> each recursive step.
>

There is a difference between a function that is recursive and values on 
the heap that are cyclic. The recursive functions issue seems to be with 
what order to output compiled javascript code in, when there are mutually 
recursive functions, as one may not be defined at the point in time when 
another needs to access it. The cyclic structures on the heap issue, is to 
do with how to make garbage collection very easy in a language that does 
not need cyclic structures.

I think this page is confusing because it discusses both issues at the same 
time:
https://gist.github.com/evancz/07436448b7d6c947f21742dab46d1218



-- 
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: Approval Queue and Moderation Slowdowns

2017-11-30 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, November 29, 2017 at 8:06:58 PM UTC, Brian Hicks wrote:
>
> The current candidate is Discourse.
>

It sounds like a great idea. There is a need for slower and less chat based 
discussion than Slack, that maintains a free searchable history. If you are 
putting in the work to give us that with a much better user experience than 
we get here, then thanks and I think it will be a success.

-- 
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: Randoms as LazyLists

2017-11-30 Thread 'Rupert Smith' via Elm Discuss

On Thursday, November 30, 2017 at 10:29:42 AM UTC, Rupert Smith wrote:
>
> I need to use Decode.lazy to do this. Is that memoized? Is that how 
> decoders can create recursive values? Other than that, I don't see how they 
> could.
>

Do you need to start with a recursive object in Javascript, then decode 
into Elm using Decode.lazy, to produce a recursive value in Elm? 

Approximately:

var rec = { field : rec };

myapp.ports.myport.send(rec);



type Rec = 

Rec
{
field : Rec
}


port myport : (Rec -> msg) -> Sub msg



But of course, that isn't going to compile as ports won't decode tagged 
union types, and you need a tagged union type to define a recursive type.

-- 
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: Randoms as LazyLists

2017-11-30 Thread 'Rupert Smith' via Elm Discuss

On Monday, November 27, 2017 at 9:06:38 PM UTC, Mark Hamburg wrote:
>
> Recursive decoders have the same issues.
>

I'll see if I can get my head around that. I use recursive decoders to 
decode JSON into recursive types, but the values I output from this are not 
recursive. I did not realize it is possible to build a recursive value with 
decoders? Do you have an example?

These are mutually recursive types from a content model that I have been 
working with. If the server sends me some content with a list of 
relationships, and one of the relationships refers to the original content, 
I will end up with multiple copies of the original content in the structure 
decoded into Elm. 

I need to use Decode.lazy to do this. Is that memoized? Is that how 
decoders can create recursive values? Other than that, I don't see how they 
could.

type Content =
Content
{
slug : Maybe String
, path : Maybe String
, contentType : Maybe (ContentType)
, model : ContentModel
, relationships : Maybe (List Relationship)
, container : Maybe (List Content)
, id : Maybe String
}


type Relationship =
Relationship
{
subject : Maybe (Content)
, predicate : Maybe PredicateType
, object : Maybe (Content)
, id : Maybe String
}




-- 
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: Randoms as LazyLists

2017-11-27 Thread 'Rupert Smith' via Elm Discuss
On Monday, November 27, 2017 at 4:33:57 PM UTC, Mark Hamburg wrote:
>
> That page already has an example built using the decoder APIs so unless 
> something is changing to disallow the creation of such cyclic decoders, 
> cycles remain. 
>

I'm looking at the page. I don't see a cyclic example built with the 
Decoder API. What am I 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.


Re: [elm-discuss] Re: Randoms as LazyLists

2017-11-27 Thread 'Rupert Smith' via Elm Discuss

On Monday, November 27, 2017 at 7:50:01 AM UTC, Mark Hamburg wrote:
>
> P.S. Cyclic structures can be avoided by having the compiler perform a 
> strongly connected component analysis (e.g., using Tarjan's algorithm) and 
> disallowing any SCC's that include anything other than function 
> definitions. In fact, not doing so likely leaves open other cyclic cases 
> and hence getting rid of Lazy likely does not eliminate cycles and instead 
> just narrows the cases for which Elm is suitable.
>

My hunch is that enough has been done to make cyclic structures impossible, 
but I have made no detailed analysis to support that. If all data 
structures are immutable, then references within them have to be created 
when the structure is first created. The first structure in a cycle to be 
created must contain a reference to another structure in the cycle, for a 
cycle to be formed, but as the other structures have not yet been created, 
this cannot be done.

I think you should post an example of building a cyclic structure here, if 
you think it can be done:

https://gist.github.com/evancz/07436448b7d6c947f21742dab46d1218 

-- 
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: Array map with start and end

2017-11-23 Thread 'Rupert Smith' via Elm Discuss

On Thursday, November 23, 2017 at 2:28:50 AM UTC, Matthieu Pizenberg wrote:
>
>
> Could JsArray.elm by made to work with JavaScript typed arrays? 
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
>>
>
> That was exactly what I was wondering. I peaked at the elm and kernel code 
> and wanted to try to hack something to wrap ArrayBuffer. I got stopped at 
> the step of compiling the elm plateform at master ^^, my system ghc beeing 
> 8.2 and I don't have enough haskell-fu yet to manage multiple haskell 
> versions :)
>

Do you need to rebuild the compiler for this?

I may be wrong, but kernel hacking can be done by using elm-github-install, 
by putting a substitution for elm-lang/core in your elm-package.json like 
this:

"dependency-sources": {
"elm-lang/core": "../my-hacked-core"
}


Then you can try out kernel modifications without needing to rebuild the 
whole Elm distribution?
 

> As a side note, I just went to a NixOS [1] meetup yesterday evening, 
> really cool stuff. I think this nix package manager [2] will help me deal 
> with those dependencies issues!
>

I really want to try NixOS, but it will have to wait until I have a good 
amount of time on my hands to play around with it. 

-- 
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: Array map with start and end

2017-11-22 Thread 'Rupert Smith' via Elm Discuss

On Tuesday, November 21, 2017 at 10:47:02 AM UTC, Robin Heggelund Hansen 
wrote:
>
> Something like 
> https://github.com/Skinney/core/blob/master/src/Elm/JsArray.elm ? It's 
> what is used as the basis for Arrays in 0.19. It is not planned to be 
> opened for use outside of elm-lang/core, but if it fits your usecase 
> better, I'm sure Evan would be interested in hearing about it.
>
> (JsArray is a thin wrapper over javascript arrays. Any operation that 
> modifies the underlying structure causes a complete copy, but get and folds 
> are very fast. Slicing when start === 0 is still going to be faster using 
> Elm Arrays as it is a tree structure. On the other hand, it should be 
> fairly easy to create a "view" instead of slicing, but that might give you 
> problems with space leaks.)
>

Yes.

Something I forgot to mention about Java nio.Buffers is that they are byte 
array buffers. There is mechanism by which int and float (and short, char, 
lond and double) are overlayed as views onto byte buffers.

The reason I mention this is that as yet Elm does not have any support for 
binary buffers, and it might also be worth thinking about that issue at the 
same time.

Could JsArray.elm by made to work with JavaScript typed 
arrays? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays

-- 
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: Array map with start and end

2017-11-21 Thread 'Rupert Smith' via Elm Discuss
On Monday, November 20, 2017 at 5:29:25 PM UTC, Francisco Ramos wrote:
>
> Ultimately, I'd like to rewrite NumElm using the elm-ndarray. Not sure how 
> I'm gonna do this without writing kernel code. Linear algebra operations 
> such as Inverse, Pseudo-inverse, Singular value decomposition, Eigenvalues 
> and eigenvectors, etc... I simply have no idea how I'm gonna implement 
> this. Need to have a look at solutions in Haskell for inspiration.
>

I suspect you are up against a tough impedance mismatch between immutable 
arrays for functional languages, and fast flat arrays for pure number 
crunching.

The tree structured arrays for functional languages are designed to allow a 
new version to be created from an existing array, without copying the 
entire array. Well, a balance between copying the least amount whilst 
keeping the tree fairly shallow for fast access.

Arrays of floats for number crunching ideally just want to be stored flat 
in RAM, so you can point an optimized for-loop at them or your GPU.

You could also look at Java nio.Buffer for some inspiration? These allow 
off-heap 'direct' buffers to be created, but have an interface on the Java 
language side to manipulate them. You can for example take a 'slice' of 
such a buffer, and it give you a so-called flyweight object as the result, 
that is, a start offset and length into the original buffer, but sharing 
the same data. 'slice' therefore is a very efficient operation.

This scheme won't translate into immutable functional data structures 
without modification. For example, to modify such a buffer in an immutable 
way, would mean copying the entire thing. I just mention it as a possible 
source of inspiration to help you think about your design.

Perhaps this is already what you have in mind for ndarray? A structure that 
is more efficient for your use case, but that is wrapped in an immutable 
functional API to make it play nicely with the host language.

-- 
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: Decoding a json property with different types of values

2017-11-20 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 17, 2017 at 3:19:55 PM UTC, Thiago Temple wrote:
>
> I have situation where I have to a jso object similar to this
>
> { "level": 1, "displayValue": "some text", "dataValue": "a string with 
> the value" }
>
> { "level": 1, "displayValue": "some text", "dataValue": { "name": "xxx", 
> "scope": "" } }
>
> Both cases for dataValue are valid, it can either have a string or an 
> object.
>
> I have created types as such:
>
> type DataValue
>   = Val String
>   | Key KeyType
>
> type alias KeyType =
>  { name: String, source: String }
>
> type alias MyObj = 
>  { level: Int, displayValue: String, dataValue: DataValue}
>
> How can I decode dataValue for MyObj?
>
> Thanks 
>

I think the Decode.oneOf suggestion from Aaron VonderHaar is most likely to 
be useful to you.

Just to give another way, here is some decoder code for a JSON structure 
where I also added an explicit @type field to indicate which type it is to 
be decoded to. This is a little more complex, and in my case required the 
back-end to play nicely and insert the @type fields too. It does avoid the 
trial and error approach of 'oneOf' too:

{-| 
Describes the ContentModel view type. 
-} 
type ContentModel = 
TitledAsContentModel Titled 
| MdContentAsContentModel MdContent 
| PanelAsContentModel Panel 
 
{-| 
A JSON encoder for the ContentModel type. 
-} 
contentModelEncoder : ContentModel -> Encode.Value 
contentModelEncoder model = 
  case model of 
TitledAsContentModel titled -> titledEncoder titled 
MdContentAsContentModel mdContent -> mdContentEncoder mdContent 
PanelAsContentModel panel -> panelEncoder panel 
 
{-| 
A JSON decoder for the ContentModel type. 
-} 
contentModelDecoder : Decoder ContentModel 
contentModelDecoder = 
  let 
toContentModel typeName = 
  case typeName of 
"Titled" -> map TitledAsContentModel titledDecoder 
"MdContent" -> map MdContentAsContentModel mdContentDecoder 
"Panel" -> map PanelAsContentModel panelDecoder 
_ -> Decode.fail ("unknown type: " ++ typeName) 
  in 
field "@type" Decode.string 
  |> andThen toContentModel





-- 
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: Randoms as LazyLists

2017-11-20 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 17, 2017 at 1:25:02 PM UTC, GordonBGood wrote:
>
> The rational to depreciating these seems to be performance when applied to 
> their limited use in tests and I see that, as I tried to make changes to 
> Lazy that would improve its lack of performance when run on some JavaScript 
> engines that handle internal functions calling functions very poorly.
>

Gordon, it took me a bit of digging through various docs and updates on 
elm-dev to understand it, but... the rational for deprecating elm-core/lazy 
with memoization, is that it allowed recursive structures to be created on 
the heap, and all other ways in which that was possible have been 
eliminated. This is all described here:

https://gist.github.com/evancz/07436448b7d6c947f21742dab46d1218

It seems to be partly motivated by making garbage collection simpler - 
presumably with WebAssembly in mind. I honestly don't know much of a real 
advantage that is, but it seems that was the trade-off decision that has 
already been made.

-- 
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: Array map with start and end

2017-11-17 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 17, 2017 at 8:25:22 AM UTC, Francisco Ramos wrote:
>
> Hi there,
>
> Was wondering how I can map over an array with a start and end indexes. I 
> know I could slice the array and then map, but performance is a concern and 
> slicing is O(N) where N = end - start, plus the actual mapping, another 
> O(N).
>
> Maybe there is another way where I just loop once over the array?
>

You could write your own using Array.get. But I can see that will be a 
PITA, as it returns a Maybe, so you might also end up having to supply a 
default value for the case where get gives you a Nothing, but in practice 
that default will never be used. Or have your custom map function also 
return a Maybe, and output Nothing if the indexes are out of bounds and 
Array.get returns Nothing?

-- 
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: Randoms as LazyLists

2017-11-14 Thread 'Rupert Smith' via Elm Discuss
On Monday, November 13, 2017 at 11:48:19 PM UTC, GordonBGood wrote:
>
> The LazyList library as it exists is seriously flawed as it crashes for 
> many cases for infinite length lazy lists, which is probably why there is 
> that caution. Please see my extensive PR which fixes almost every function 
> so they can handle infinite length lazy lists within the guidelines.


That is not so good, as infinite lists is much of the point of lazy lists. 
Lets ping the package maintainer and find out why your PR is just sitting 
there since February.

-- 
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: Randoms as LazyLists

2017-11-14 Thread 'Rupert Smith' via Elm Discuss
On Monday, November 13, 2017 at 5:49:32 PM UTC, art yerkes wrote:
>
> 'iterate' is the right way to do what you're looking for.  No idea why 
> they chose to expose that.
>
> generate : Generator a -> Seed -> LazyList a
> generate generator seed =
> let start = Random.step generator seed in
> LL.iterate
> (\(v,s) -> Random.step generator s)
> start
> |> LL.map Tuple.first
>

Yes, this is the same code as I posted originally (generate2). It just 
seemed overkill to have to apply a 'map first' when it can be accomplished 
in a single pass using the Cons constructor.

-- 
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: Randoms as LazyLists

2017-11-13 Thread 'Rupert Smith' via Elm Discuss
On Saturday, November 11, 2017 at 6:33:34 PM UTC, art yerkes wrote:
>
> I always interpreted the warning in the documentation as "Don't use the 
> name LazyListView or the Nil and Cons constructors, instead using head, 
> tail and headAndTail for most pattern matchng".  I think it makes sense not 
> to use the internal representation given that Dict and Array change when 
> better implementations arise.  Does any code elm code actually pattern 
> match these instead of using the functions?  Always thought it was weird to 
> have this type exposed at all.
>

I cannot use the 'cons' constructor though, as it is not lazy enough:

generate : Generator a -> Seed -> LazyList a
generate generator seed =
let
( value, newSeed ) =
Random.step generator seed
in
cons value (generate generator newSeed)


Runs out of stack space, as the recursive step is evaluated eagerly.

I think it is strange to expose a type but recommend not using it. Either a 
type is opaque and cannot be used directly, or exposed and it is perfectly 
ok to use it.


-- 
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: Randoms as LazyLists

2017-11-10 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 10, 2017 at 4:45:54 PM UTC, Rupert Smith wrote:
>
> The function uses the exposed Lazy.List.LazyListView type, which I would 
> rather avoid if it makes sense to:
>

The documentation says:

"It is not recommended to work with this type directly. Try working solely 
with the provided functions in the package."
 
But I wonder, does this really make sense? Its not like this library is 
going to swap out that representation for another one at a later time is 
it? In which case exposing the type and working with it directly, which is 
needed for pattern matching anyway, is no different than working with say 
the List type directly.
 

-- 
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] Randoms as LazyLists

2017-11-10 Thread 'Rupert Smith' via Elm Discuss
I have a function that takes a random Generator and turns it into a 
LazyList. The reason for this is so that I can combine random streams 
together with other lazy streams that I have using the Lazy.List library.

The function uses the exposed Lazy.List.LazyListView type, which I would 
rather avoid if it makes sense to:

generate : Generator a -> Seed -> LazyList a
generate generator seed =
let
( value, newSeed ) =
Random.step generator seed
in
lazy <|
\() ->
Cons value (generate generator newSeed)

This version uses iterate on a (a, Seed) -> (a, Seed) function, but then 
requires a map on the tuple to extract just the random items:

generate2 : Generator a -> Seed -> LazyList a
generate2 generator seed =
let
firstValueSeed =
Random.step generator seed

step ( value, seed ) =
Random.step generator seed
in
LL.iterate step firstValueSeed
|> LL.map first

Is there some obvious way of doing this without the extra map operation? or 
perhaps that will compile down efficiently anyway.

Does there perhaps need to be a variation on the Lazy.List.cons constructor 
that takes a '() -> LazyList a' argument to allow the cons operation to be 
passed as a continuation?

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: Json.Decode without failing on the first error?

2017-11-09 Thread 'Rupert Smith' via Elm Discuss
On Thursday, November 9, 2017 at 2:39:45 PM UTC, Ilias Van Peer wrote:
>
> Yeah, I did that some time ago - 
> package.elm-lang.org/packages/zwilias/json-decode-exploration/latest
>
> Demo here, the very last one in the output is a scenario not unlike yours 
> :) https://ellie-app.com/3vVLfrNDnSXa1/2
>

That is exactly what I want, thank you.

-- 
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: Expanding competence

2017-11-09 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, November 8, 2017 at 6:18:39 AM UTC, David Legard wrote:
>
> Many thanks for that recommendation.
>
> Yes, it is the back-end part that I was concerned about.
>

Try this, makes it easy to get started with Elm on AWS, and it can run 
locally too:

https://github.com/ktonon/elm-serverless 

-- 
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: What build system do you prefer for Elm?

2017-11-07 Thread 'Rupert Smith' via Elm Discuss
On Sunday, November 5, 2017 at 8:19:37 AM UTC, Simon wrote:
>
> I use my own starter, which includes hot reloading: 
> https://github.com/simonh1000/elm-webpack-starter
>

I'm intrigued to try hot reloading. Does it only work if you don't change 
the type of the 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.


Re: [elm-discuss] Re: The NumPy for Elm

2017-11-03 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 3, 2017 at 10:06:49 AM UTC, Francisco Ramos wrote:
>
> Sounds good. Remember, I built NumElm with Machine Learning algorithms in 
> mind. So I added mostly the functionality used in such algorithms. 
>

I suppose polynomial fitting is a kind of machine learning. I am a little 
bemused by how much ML currently seems to be focused on neural networks, I 
always thought kernel methods would overtake the neural approach. Kernel 
methods map non-linear problems back into linear ones with higher 
dimensionality, just like how this polynomial curve fitting turns a 
polynomial into a linear fitting problem with as many dimensions as the 
degree of the polynomial.

I created this gist for you. Just now, and without testing, so I'm not sure 
> if it works, but it looks like what you're looking for. Please give it a 
> try and let me know:
>
> https://gist.github.com/jscriptcoder/3be0e4186bc8098d1310e6e7fb3bf441
>

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] Re: The NumPy for Elm

2017-11-03 Thread 'Rupert Smith' via Elm Discuss
On Thursday, November 2, 2017 at 5:28:15 PM UTC, Francisco Ramos wrote:
>
> Hey Rupert, 
>
> Let me have a look when I have a little bit of time and I'll get back to 
> you.
>
> Fran
>

I will also have a go at implementing the polynomial stuff in my own 
Plynomials.elm built on top of what NumElm already has. If I make some good 
progress with it, then we can look at pulling it into NumElm.

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: ELM = JAVASCRIPT REINVENTED (PART 1)

2017-11-03 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 3, 2017 at 4:08:37 AM UTC, Richard Feldman wrote:
>
> Any ways in which Elm's design resembles JS are almost certainly 
> coincidental!


No programmers were harmed in the making of this movie... 

-- 
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: The NumPy for Elm

2017-11-02 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, November 1, 2017 at 8:38:48 PM UTC, Rupert Smith wrote:
>
> How would I write a curve fitting alrogithm with this? So I have a 3rd 
> order polynomial:
>
> y = a + b.x + c.x^2 + d.x^3
>
> and some linear algebra on 100 data points will yield values for a, b, c 
> and d. I'll post up the python code tomorrow, it seems to use an in-built 
> fit_curve() function.
>

Here is the NumPy code that I would like to convert to NumElm: 

import time
import numpy as nm

def get_curve(measurements, timestamps):
  y = measurements
  x = timestamps
  z = nm.polyfit(x, y, 3)
  f = nm.poly1d(z)


  return f


but polyfit and poly1d have not been ported to NumElm. I will take a look 
into how to port them.

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: Multiple "Middleware" pattern instead of single *.program

2017-11-02 Thread 'Rupert Smith' via Elm Discuss
On Thursday, November 2, 2017 at 12:09:55 AM UTC, Martin Janiczek wrote:
>
>
>1. Is this a good idea at all?
>
> Having stacked a few programs together by hand, this strikes me as an 
excellent idea and one that is worth exploring.

One problem I had was with TimeTravel.program which I was wrapping a 
RouteUrl.navigationApp with. All the messages were then nested at the 
time-travel level, and its UI did not support nested filtering, so I could 
not easily filter out animation messages. It occurs to me that if each 
middleware knows about the next layer, and has wrap/unwrap functions for 
it, that it would be possible to have set up the time-travel layer to 
unwrap the nested messages, if I had such a system as yours.

Would love to see what a navigation example looks like.

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: The NumPy for Elm

2017-11-01 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, October 31, 2017 at 12:32:06 PM UTC, Francisco Ramos wrote:
>
> https://github.com/jscriptcoder/numelm
>
> Please, any feedback would be highly appreciated.
>

So, I have a project at work where we are using NumPy running on AWS. I 
have been looking into how to write AWS Lambda functions using Elm, and 
found this excellent project:

http://package.elm-lang.org/packages/ktonon/elm-serverless/latest
https://github.com/ktonon/elm-serverless

One cool thing about how it is implemented, is that it uses a wrapper 
around the Elm program to establish a new type of 'Program'. As such it 
doesn't have ports or hacked any kernel code - yet it is definitely 
stretching Elm well outside of it comfort zone as a client side only 
language. I think that is pretty neat, because my instincts would have been 
either to use ports or do some kernel hacking and ended up with code that I 
could not then share on package.elm-lang.org. I somehow automatically 
assume that doing anything with elm that is not TEA is going to involve 
native code in such a way that a non-shareable package is created and the 
back-door that is elm-github-install will be used.

My work project involves running an algorithm in NumPy against 10s or 100s 
of days of data points and doing some curve fitting to then make an 
estimate of when some equipment is going to exceeed its specified operating 
parameters (I'm being vague because I signed an NDA).

So once I get my Elm Lambda functions experiment working nicely, I can try 
out converting the NumPy algorithms into NumElm. All the NumPy algorithms I 
have are quite short, its fairly simple stuff we are doing. Even if NumElm 
turns out a bit slow, its only a few hundred data points at most so I think 
it will be ok. I also think fetching the data from the database (Athena) 
will tend to dominate rather than the CPU work.

How would I write a curve fitting alrogithm with this? So I have a 3rd 
order polynomial:

y = a + b.x + c.x^2 + d.x^3

and some linear algebra on 100 data points will yield values for a, b, c 
and d. I'll post up the python code tomorrow, it seems to use an in-built 
fit_curve() function.

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.


Re: [elm-discuss] The NumPy for Elm

2017-10-31 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, October 31, 2017 at 12:42:07 PM UTC, Peter Damoc wrote:
>
> Hi Fran, 
>
> I would be interested in seeing performance benchmarks agains NumPy. 
> I'm expecting NumElm to be worse but I'm curious how much worse it is. :) 
>
> In any case, congrats for creating this!
>

I'm expecting the Elm version to be faster. C'mon 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.


[elm-discuss] What build system do you prefer for Elm?

2017-10-31 Thread 'Rupert Smith' via Elm Discuss
I've been using grunt up until now. Looking into webpack at the moment as a 
few github projects I've been looking at use it.

Anyone got any thoughts on the advantages/disadvantages of the various 
possibility wrt 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.


[elm-discuss] Re: Higher-order functions with a function using an extensible record?

2017-10-11 Thread 'Rupert Smith' via Elm Discuss
On Sunday, October 8, 2017 at 6:48:39 PM UTC+1, art yerkes wrote:
>
> It's a niggle, but I think it's more correct to say that type inference 
> isn't completely decidable in the presence of subtyping.
>

Fair enough. Even with subtyping, it is sometimes obvious that a type can 
still be correctly inferred. Unfortunately, not in the general case.

-- 
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: Elm feasibility for large, complex desktop browser application with dependencies on many newer web APIs

2017-10-11 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, October 10, 2017 at 8:55:44 PM UTC+1, Gareth Ari Aye wrote:
>
> * react and redux for managing components and application state
>

This is the part that is most like Elm, so you might consider porting that 
to Elm first? 

-- 
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: Easy way to set up a caching proxy for github to make elm-install run faster?

2017-10-11 Thread 'Rupert Smith' via Elm Discuss
On Friday, October 6, 2017 at 3:42:20 PM UTC+1, Chad Woolley wrote:
>
> I asked Evan about this at last week's ElmConf, and he said in the next 
> release of Elm, there will be changes that make it easier to cache 
> dependencies which have previously been downloaded.
>

Yes, elm-install already does this. Unfortunately, as it just clones a git 
repo, it ends up doing a significant amount of work just to decide if a new 
version has become available since the last cached one. I wonder though if 
it is doing this as efficiently as possible?

In Java land we have the Maven repositories, where artifacts are packages 
as binaries (.jar files), and the repo meta data is held separately in a 
small xml file. It means checks for updates only requires downloading that 
small xml file. You can also limit how frequently updates are checked for.

There are also package managers such as Nexus, that are easy to set up as 
proxies on the central repository. Once you have Nexus running on you local 
development network and configured nicely, it all goes much faster. In 
fact, I also have an apt-proxy running in my development network as I am 
frequently creating new Debian virtual machines.

It would likely be possible to write a plugin for Nexus that supports Elm - 
it started out as a Maven package manager but has now evolved to cover 
other packaging formats like npm.

Anyway, I'm sure Evan has will work things out nicely for Elm 0.19, and 
probably not much point in figuring out the direction of third party 
tooling to fill any gaps until that is out.

-- 
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: Higher-order functions with a function using an extensible record?

2017-10-06 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, October 4, 2017 at 3:19:45 PM UTC+1, Rémi Lefèvre wrote:
>
> When I try to build this code:
>
> type alias Named a =
>{ a | name : Maybe String }
>
> getName : Named a -> Maybe String
> getName { name } =
>name
>
> type Element
>= AnElement { name : Maybe String }
>| AnotherElement { name : Maybe String }
>
> mapNamed : (Named a -> b) -> Element -> b
> mapNamed func element =
>case element of
>  AnElement e ->
> func e
>
>  AnotherElement e ->
> func e
>
> getElementName : Element -> Maybe String
> getElementName e =
>mapNamed getName e
>


The Element type here is analogous to object oriented programming - you 
have a parent type Element, with 2 sub-types AnElement and AnotherElement. 
Your 'mapNamed' function is like a virtual method - it knows just enough 
about the overall type of Element to work with all 'sub-types' of it.

As Ilias points out, the type of the records within the Element type is 
'Named {}' but the function is of type 'Name a -> b'. So you are thinking 
that the 'a' variable should get bound to {} when this function is invoked?

This would work in an object oriented language, but not Elm. The reason is 
that Elm does not support sub-typing at all. Elm has type inference - it 
looks at the type of function you wrote and deduced that the type of 'func' 
should be 'Named {} -> b' and finds that it does not match with what you 
specified in the type signature, so it fails the type checking. 

'Named {}' is a sub-type of 'Named a' in languages that support sub-typing. 
It makes sense because anywhere you can use a 'Named a', you should also be 
able to use a more specific type such as 'Named {}' or 'Named Int' or 
whatever.

Elm has type inference and type inference does not work with sub-typing. 
The typing problem is semi-decidable. This means that given the type of an 
expression, it is possible to decide whether or not that is the correct 
type of the expression. Going the other way, given an expression it is not 
possible to deduce what the type of that expression should be when 
sub-typing is allowed in the type system.

It is easy to mistake Elms extensible records for sub-typing, especially if 
you come from an OO back-ground. It is generally not worth trying to use 
extensible records at all for data modelling in Elm, because they tend to 
lead you down this blind alley very quickly. Their use case is for 
narrowing the exposure of a function to parts of a record it does not care 
about. I reference Richard Feldman's 2017 Elm Europe talk as a good 
resource to learn more about this:

https://www.youtube.com/watch?v=DoA4Txr4GUs

The moral of the story is - don't try and do OO programming in Elm, it 
won't work.

-- 
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: Easy way to set up a caching proxy for github to make elm-install run faster?

2017-10-06 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, October 4, 2017 at 5:02:30 AM UTC+1, Gusztáv Szikszai wrote:
>
> I suppose another way would be to modify elm-install such that it take a 
>> command line argument that tells it to skip checking for updates. Maybe -o 
>> for offline mode.
>>
> There is one it's the --skip-update I've added it in the v1.6.0 
>  
> release
>

Excellent, that is very helpful, 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: Easy way to set up a caching proxy for github to make elm-install run faster?

2017-10-03 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, October 3, 2017 at 4:32:09 PM UTC+1, Rupert Smith wrote:
>
> I tend to use elm-install to manage my package dependencies, as it also 
> caches them locally. However, it needs to reach out to github to check for 
> any updates, each time it is run. I am working on a slow internet 
> connection some of the time.
>
> Does anyone know of an easy way to set up a caching proxy for github? The 
> first time a repository is cloned from github, the cache should make a copy 
> of the clone. Maybe a config option to tell it how often to update any 
> clones it holds, once a day will be enough for me.
>

I suppose another way would be to modify elm-install such that it take a 
command line argument that tells it to skip checking for updates. Maybe -o 
for offline mode. 

-- 
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] Easy way to set up a caching proxy for github to make elm-install run faster?

2017-10-03 Thread 'Rupert Smith' via Elm Discuss
I tend to use elm-install to manage my package dependencies, as it also 
caches them locally. However, it needs to reach out to github to check for 
any updates, each time it is run. I am working on a slow internet 
connection some of the time.

Does anyone know of an easy way to set up a caching proxy for github? The 
first time a repository is cloned from github, the cache should make a copy 
of the clone. Maybe a config option to tell it how often to update any 
clones it holds, once a day will be enough for me.

-- 
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: elm-outdated

2017-10-01 Thread 'Rupert Smith' via Elm Discuss
On Saturday, September 30, 2017 at 6:27:24 PM UTC+1, Fedor Nezhivoi wrote:
>
> Hi folks!
>
> Those of you who are writing production applications probably have to look 
> after outdated dependencies from time to time. Usually it’s a bit of a pain 
> since there is no built-in way in elm-package to check that. So I’ve made 
> a small tool  which helps 
> checking which dependencies are outdated.
>
> Here is example output for elm-spa-example:
>
>
> 
> ​
>

Thanks, very useful.

-- 
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: Issues with drag & drop (also reproducible in drag example on elm website)

2017-09-25 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 15, 2017 at 12:27:27 PM UTC+1, Jan Hrček wrote:
>
> I suspect that this behavior has something to do with text withing the 
> dragged element's inner text being selectable.
> When I add the following style attributes to the drag example, I can no 
> longer reproduce the issue no matter how fast/sloppily I click:
>   ,  "user-select" => "none"
>   , "-moz-user-select" => "none" 
>

I should have read more carefully. I think things may be working similarly 
to how I described. The mouse down event occurs not on the text, but then 
the pointer moved over the text and that somehow results in the mouse up 
event being lost or interpreted as selecting the text. I will try this in 
my application and see if I get the error always when the mouse moves over 
text, and also disabling selection. Good observation. 

-- 
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: Issues with drag & drop (also reproducible in drag example on elm website)

2017-09-25 Thread 'Rupert Smith' via Elm Discuss

On Friday, September 15, 2017 at 12:27:27 PM UTC+1, Jan Hrček wrote:
>
> I've been figthing with the following drag and drop issue: when performing 
> multiple drag & drop operations in rapid succession it sometimes happes 
> that drag is in progress, even though my mouse key is up.
>

Also happens in MS Edge.

I suspect the following is happening: Mouse goes down on the drag-able 
item, but you are also moving the pointer at the same time. Elm gets the 
mouse down event and begins the drag. Meanwhile you have moved the pointer 
outside of the drag-able item, and release the button outside of it. As 
this event is not on the item, it does not reported to Elm as a mouse up 
event.

I also see a very similar issue in my code, where I have a piece of 
editable content that I want to highlight when the mouse goes over it to 
show that it can be clicked and edited. Sometimes it fails to pick up the 
mouse out event and remains highlighted when it should not. I have not 
really explored the issue in depth, but I need to, so I am interested in 
how to solve this.

One question that comes to mind, is this a problem that is exclusive to 
Elm? Or do all javascript applications potentially suffer from it? Is it 
just a question of thinking more clearly about where in the DOM structure 
you need to pick up the mouse up/down or in/out events?

-- 
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] Strange compiler error - cannot find a field that is obviously there.

2017-09-11 Thread 'Rupert Smith' via Elm Discuss
On Monday, September 11, 2017 at 6:39:32 PM UTC+1, Ian Mackenzie wrote:
>
> 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.
>

Yes, there are type annotations there. It is a good point though - I'll 
have a careful check through that I didn't miss any.

-- 
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] Strange compiler error - cannot find a field that is obviously there.

2017-09-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 8, 2017 at 7:52:34 PM UTC+1, Eelco Hoekema wrote:
>
> That absolutely looks like you still some old compiled stuff lying around 
> somewhere. What happens if you copy the code to a clean directory, run 
> elm-package install again?
>

I have been deleting 'elm-stuff', is there more I need to delete to clean 
things up?
 

> Other possible reasons for weird errors: did you recently upgrade elm?
>

No. 

-- 
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: Strange compiler error - cannot find a field that is obviously there.

2017-09-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 8, 2017 at 10:47:04 AM UTC+1, Rupert Smith wrote:
>
> I fixed the code so that the Account model has the uuid field, and the 
> module which depends on that also now has the uuid field. A clean compiler 
> run with elm-stuff deleted says that the dependant module has an extra 
> 'uuid' field in it, not in the model, and a subsequent compiler run gives 
> the original error message. The field is there and my code looks correct, 
> yet the compiler won't run it.
>

I wonder if it could be to do with my module being called 'Model', but 
there is also a Model type defined in the same scope. I have seen some 
strange compiler errors caused by a module/type name clash before. So I 
will try renaming the module or importing it under a different name. 

-- 
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: Strange compiler error - cannot find a field that is obviously there.

2017-09-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 8, 2017 at 9:37:16 AM UTC+1, Rupert Smith wrote:
>
> On Friday, September 8, 2017 at 9:35:14 AM UTC+1, Rupert Smith wrote:
>>
>> Has anyone seen an error like this before? I don't see it in the github 
>> elm-compiler issues, so I though I might try and put together an SSCCE for 
>> it. Which I may manage to do, if my hypothese
>>
>
> Which I may manage to do, if my hypothesis is correct. 
>

Bugger. 

I fixed the code so that the Account model has the uuid field, and the 
module which depends on that also now has the uuid field. A clean compiler 
run with elm-stuff deleted says that the dependant module has an extra 
'uuid' field in it, not in the model, and a subsequent compiler run gives 
the original error message. The field is there and my code looks correct, 
yet the compiler won't run it.

If I try to pull out just an isolated example to make an SSCCE out of... 
the problem goes away.

-- 
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: Strange compiler error - cannot find a field that is obviously there.

2017-09-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 8, 2017 at 9:35:14 AM UTC+1, Rupert Smith wrote:
>
> Has anyone seen an error like this before? I don't see it in the github 
> elm-compiler issues, so I though I might try and put together an SSCCE for 
> it. Which I may manage to do, if my hypothese
>

Which I may manage to do, if my hypothesis is correct. 

-- 
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] Strange compiler error - cannot find a field that is obviously there.

2017-09-08 Thread 'Rupert Smith' via Elm Discuss
When I try to compile this:

module Model exposing (..)

type Account
= Account
{ uuid : String
, username : Maybe String
, password : Maybe String
, root : Maybe Bool
, id : Maybe String
}




accountEncoder : Account -> Encode.Value
accountEncoder (Account model) =
[ Just ( "uuid", Encode.string model.uuid )
, Maybe.map (\username -> ( "username", Encode.string username )) model.
username
, Maybe.map (\password -> ( "password", Encode.string password )) model.
password
, Maybe.map (\root -> ( "root", Encode.bool root )) model.root
, Maybe.map (\id -> ( "id", Encode.string id )) model.id
]
|> catMaybes
|> Encode.object



The compiler is somehow blind to the 'uuid' field being there:


-- TYPE MISMATCH - src/auth-client/elm/Model
.elm


`model` does not have a field named `uuid`.


176| [ Just ( "uuid", Encode.string model.uuid )
^^
The type of `model` is:


{ id : Maybe String
, password : Maybe String
, roles : Maybe (List Role)
, root : Maybe Bool
, salt : Maybe String
, username : Maybe String
}




Which does not contain a field named `uuid`.



Erm.. what?

Interestingly, if I clear out 'elm-stuff' and try again, it fails but with 
different errors relating to other modules, some of which depend on this 
one. I don't get this error, but I do get an error in the Account.Service 
module which depends on this Model module saying that some of its code 
tries to create Accounts without uuids.

I just added the 'uuid' field, and the modules that consume this one do not 
yet have it in their code. My hypothesis is that the later modules are 
compiling some of the way, some information from that is being written to 
disk, and on the next compilation run that information is found to conflict 
with the Account type and the compiler comes out with this confusing error 
message. I see .elmi and .elmi files under 'elm-stuff' for the 
Account.Service module which depends on this one.

Perhaps if the compiler fails to compile a module it should do so more 
atomically, and not output a .elmi and .elmo files?
Also, getting different errors on two consecutive compiler runs is not 
idempotent behaviour.

Has anyone seen an error like this before? I don't see it in the github 
elm-compiler issues, so I though I might try and put together an SSCCE for 
it. Which I may manage to do, if my hypothese

-- 
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 and Swagger - what is currently available?

2017-09-07 Thread 'Rupert Smith' via Elm Discuss
Swagger is a data model that describes a REST API, the URLs of endpoints 
and json-schemas describing the json that they accept or produce. I didn't 
find anything in package.elm-lang.org relating to it.

I did find this github project which implements a CLI for converting a 
Swagger .json into Elm Encoders and Decoders, which is pretty neat.

https://github.com/ahultgren/swagger-elm

Do let me know if you know of any other Elm/Swagger projects.


-- 
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: Elm as templating engine

2017-09-04 Thread 'Rupert Smith' via Elm Discuss

On Sunday, September 3, 2017 at 12:18:26 AM UTC+1, Birowsky wrote:
>
> Trying to use elm as a templating engine for AMP pages. But they have 
> specific requirements where I need to specify attributes without values. Is 
> that possible with some elm construct?
>
> https://www.ampproject.org/docs/tutorials/create/basic_markup
>
> for an example:
>
> amp =
> boolProperty "⚡" True
>
>
> creates `⚡="true"` instead of just the `⚡`
>

I know its horrible, but the only way I can think of to do it is to use 
Html.text:

Html.text ""

Valueless attributes do not seem to be allowed by the Elm virtual DOM code, 
even though they can be valid Html:

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

-- 
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 with one message

2017-08-24 Thread 'Rupert Smith' via Elm Discuss
On Thursday, August 24, 2017 at 8:47:24 AM UTC+1, Peter Damoc wrote:
>
> Without  using Cmds and/or Subs it is an interesting approach if you use 
> it for managing very small bits of state (the open/close status of a 
> dropdown) but I'm afraid that it might bring performance problems if you 
> use it for the entirety of the app. 
> You basically have to computer all the possible future states of the app. 
>

Not so sure about that, as the callbacks seem to only be invoked in 
continuations?:

Temei.view data.temei (\v -> c { data | temei = v })


-- 
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] best practices for handling unreachable code, i.e., how to handle situations where runtime assertions would be used in other languages

2017-08-22 Thread 'Rupert Smith' via Elm Discuss
On Monday, August 21, 2017 at 9:41:55 PM UTC+1, Dave Doty wrote:
>
> But it does make me long for runtime exceptions for those errors where you 
> know that not only the current function, but also any function that may 
> have called it, really isn't going to be able to do any error-handling or 
> recovery more sophisticated than "print error message and stack trace to 
> screen".
>

Some thoughts:

Debug.crash is Elms equivalent of "throw RuntimeException".
There is no mechanism to 'catch' these runtime exceptions.
Maybe.Nothing and Result.Error are Elms equivalent of checked exceptions. 
Dealing with Nothing or Error is equivalent to "catch (SomeExcetion e)". 
Some compensating action should be taken to recover from the exception 
(such as using a default value).

Within a 'unit of work' you should not catch and error recover from a 
runtime exception. They should really be left as a mechanism that is dealt 
with at a platform level. In Java if I throw a runtime it should either 
fall out of main() and cause the VM to exit with an error code and a stack 
trace, or fall through to application server or framework code (Spring 
Boot, Dropwizard) that my business logic is running within. The effect 
should be to terminate the current unit of work completely without 
committing any of its state, since the application is now in an unknown 
state and should not continue. In the application server or framework code 
cases, the runtime is caught and recovered from by abandoning the unit of 
work but also returning the thread that was running it to the pool so that 
it can pick up fresh work in a clean state.

Thinking of the browser as the framework, it is the only sensible place to 
catch your Debug.crash and the effect will be to terminate the Elm program. 
So elm does not need a mechanism to catch runtime exceptions.

In order of desirability, I would recommend:

1. Trying to use Elms type system to design data models that do not permit 
invalid states.
2. Enforcing 'invariants' with checks in code to rule out invalid states. 
If failures of these checks can be recovered from automatically then there 
will be no need to use Maybe (in the non-empty list example, you might 
decide max of an empty list is ok to be zero). In many cases Maybes will 
creep in. I notice Evan is always banging on about invariants; good man.
3. Don't feel so bad about using Debug.crash to mark impossible states in 
your code.

Sometimes using Debug.crash (or throw IllegalStateException) feels like you 
are being lazy, or too stupid to have found a better solution. Don't do it 
out of laziness, but do allow yourself to be too stupid. When you are too 
stupid put in the assertion and use your tests to check that it can never 
happen. Over time you get better at 1 & 2 but there is no magic solution to 
always producing perfect code with all invalid states ruled out.

-- 
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: elm-format did something change?

2017-08-16 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, August 15, 2017 at 11:37:12 PM UTC+1, Francesco Orsenigo wrote:
>
> I suppose the question is, is there a consensus on which version is 
>> considered to be the most 'definitive' for 0.18 code?
>>
>
> The last one.
> Other than that, or what you consider "last" there is no consensus and 
> it's fine.
> In fact, you don't even have to use elm-format at all or feel pressured to 
> update your old code.
> Readability will be very similar regardless, and in the end that's what 
> matters.
>

I think a 'canonical' format for source code is really helpful when working 
in teams. It basically removes wasting time on any debate about it (curly 
braces at end of line or on new line? remember that that from C/C++/Java 
days...). Once established it helps to keep patches clean and easy to work 
with.

-- 
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: elm-format did something change?

2017-08-16 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, August 16, 2017 at 6:49:25 AM UTC+1, Aaron VonderHaar wrote:
>
> 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 
> worked.  My thought was that people with less tolerance for formatting 
> changes and back-and-forth will want to stick to the stable releases, and 
> those that are able to try out new features can use the -exp version.
>

I think its a good idea, and once you get to 1.0 it will really start to 
make sense. 

-- 
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: elm-format did something change?

2017-08-15 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, August 15, 2017 at 11:11:07 AM UTC+1, Rupert Smith wrote:
>
> I am just wondering if I should update all public repositories that I 
> maintain to match the latest version of elm-format? Otherwise we have to 
> keep turning off elm-format-on-save to make nice diffs.
>

I suppose the question is, is there a consensus on which version is 
considered to be the most 'definitive' for 0.18 code? 

Given that that whole thing is pre 1.0 and should be considered alpha, does 
it really make sense at this stage to distinguish between 'exp'erimental 
and alpha releases? That is, should I just go with 0.7.0-exp as the 
canonical formatter? Or do people think that it is better to go with 
0.6.1-alpha?

-- 
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: elm-format did something change?

2017-08-15 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, August 15, 2017 at 11:18:23 AM UTC+1, Rupert Smith wrote:
>
> On Tuesday, August 15, 2017 at 11:11:07 AM UTC+1, Rupert Smith wrote:
>>
>> I recently did a full upgrade and re-installed my whole system, including 
>> elm, atom and elm-format. I notice now that when I save files elm-format is 
>> giving a huge diff compared with what I had before, particularly around 
>> comments.
>>
>
> Bugger. Latest (non-experimental) version also introduces compile errors...
>

Ok, was easy enough to fix. Just need to make sure that everything after a 
@docs is on one line, or use multiple @docs if multiple lines are needed. 

-- 
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: elm-format did something change?

2017-08-15 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, August 15, 2017 at 11:11:07 AM UTC+1, Rupert Smith wrote:
>
> I recently did a full upgrade and re-installed my whole system, including 
> elm, atom and elm-format. I notice now that when I save files elm-format is 
> giving a huge diff compared with what I had before, particularly around 
> comments.
>

Bugger. Latest (non-experimental) version also introduces compile errors...

> elm-make
Success! Compiled 11 modules.
> elm-format src/
...
> elm-make
 -- DOCUMENTATION ERROR -- ./src/TypedSvg/
Filters.elm



The following exports do not appear in your module documentation: blend
colorMatrix componentTransfer composite convolveMatrix diffuseLighting
displacementMap distantLight flood funcA funcB funcG funcR gaussianBlur 
image
merge mergeNode morphology offset pointLight specularLighting spotLight tile
turbulence


 3|>{-| SVG Filter Elements
 4|>
 5|>Typical usage:
 6|>
 7|>import TypedSvg.Filters as Fe
 8|>import TypedSvg.Filters.Attributes exposing (..)
 9|>
10|>Fe.filter []
11|>[ Fe.blend [in InSourceGraphic, in2 InFillPaint, mode 
ModeMultiply] []
12|>]
13|>
14|>@docs blend, colorMatrix, componentTransfer, composite,
15|>convolveMatrix, diffuseLighting, displacementMap, flood, funcA,
16|>funcB, funcG, funcR, gaussianBlur, image, merge, mergeNode,
17|>morphology, offset, specularLighting, tile, turbulence
18|>
19|>
20|># Light source elements
21|>
22|>@docs distantLight, pointLight, spotLight
23|>
24|>-}


-- 
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-format did something change?

2017-08-15 Thread 'Rupert Smith' via Elm Discuss
I recently did a full upgrade and re-installed my whole system, including 
elm, atom and elm-format. I notice now that when I save files elm-format is 
giving a huge diff compared with what I had before, particularly around 
comments. A little example:

{-|
Username and password based login credentials.
-}

Changes to:

{-| Username and password based login credentials.
-}

Looking at the release notes, this is all 
expected. https://github.com/avh4/elm-format/releases

I am just wondering if I should update all public repositories that I 
maintain to match the latest version of elm-format? Otherwise we have to 
keep turning off elm-format-on-save to make nice diffs.

It also strikes me that working on multiple branches and upgrading them 
could also run into problems and potentially lose the ability to cleanly 
merge patches between branches. elm-format is awesome but big whitespace 
only diffs on mature codebases with multiple work streams are not.

-- 
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: Using extensible records for optional attributes?

2017-08-14 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, August 2, 2017 at 4:17:49 AM UTC+1, Mike Austin wrote:
>
> I'm curious if it's possible to use extensible records for HTML attributes 
> instead of lists of function application such as [id "foo", class "bar"]?
> I've poked around a bit, but didn't find too much on specifically this. 
> For example, something along the lines of this:
>
>
>   let x = anchor { href = "#", id = Just "root" }
>
>
> Something along the lines of defining common attributes all being maybe 
> types, and then combining it with a record passed to a function.
>
>
>   type alias CommonAttrs a =
>{ a | id : Maybe String, class : Maybe String }
>
>   commonAttrs : a -> CommonAttrs a
>   commonAttrs x =
> { x | id = Nothing, class = Nothing }
>
>   anchor : { a | href : String } -> CommonAttrs { href : String }
>   anchor attrs =
> commonAttrs attrs
>
>
> I know that's not going to work, but something along those lines. I'm new 
> to Elm and only somewhat familiar with Haskell.
>
> Thoughts?
>

Extensible records are not as uable as they might at first seem. The reason 
for this is that they are not the same thing as sub-types and sub-types 
will never feature in a language with full type inference, like Elm, 
because they present an undecidable problem. I explored this topic in 
detail in this thread:

https://groups.google.com/forum/#!searchin/elm-discuss/extensible$20rupert%7Csort:relevance/elm-discuss/NVoWA0ZYZNM/sKDmIP_IBwAJ

The general advice is, do not use extensible records for data modelling in 
Elm. It can sometimes be convenient to write functions that restrict their 
input to a sub-set of fields in a record; it restricts the dependency of 
the function onto the smallest record type that satisfies it, which is a 
good use modular design principles. Richard Feldman gave some good examples 
in this talk:

https://www.youtube.com/watch?v=DoA4Txr4GUs

-- 
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: Drawing Directed Graphs (?) in Elm

2017-08-11 Thread 'Rupert Smith' via Elm Discuss
On Monday, August 7, 2017 at 2:34:37 PM UTC+1, Michael Jones wrote:
>
> Thank you for the suggestions. My concerns are inline with Steve 
> Schafer's. I would like a dominantly vertical alignment with a clear 
> structured hierarchy spreading evenly left & right rather than an organic 
> circular spread. I'm not well versed in any of this but my impression is 
> the that force-layout approach is less controlled.
>

Hi Michael,

It is something that I am looking into too. The graphs I am laying out are 
more like entity-relationship diagrams or UML class diagrams descirbing a 
data model. Force directed also does not quite cut it for my use case, so I 
was thinking of trying something along the lines of fitting the graph nodes 
into a grid and using search to try and search for optimal layouts 
evaluated against criteria such as avoiding overlaps, crossing edges, 
having connected nodes be neighbours and so on.

Towards this end I wrote an AI search library to use to drive the search 
for the best solutions:

http://package.elm-lang.org/packages/the-sett/ai-search/latest

Unfortunately that is about as far as I have gotten so far, too many other 
distractions. But you may also be interested in taking a search based 
approach?

-- 
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] Local third-party packages

2017-07-04 Thread 'Rupert Smith' via Elm Discuss

On Tuesday, July 4, 2017 at 7:27:10 AM UTC+1, Peter Damoc wrote:
>
> On Mon, Jul 3, 2017 at 4:15 PM, Jens Egholm  > wrote:
>
>> Just a thought; shouldn't this be available through native Elm package 
>> management?
>>
>>
> NO! 
>
> This kind of unsafe use of code is and should forever be discouraged.
>

On the whole, yes. And it is not possible to publish these packages so 
there is no danger of polluting the kernel.

The one exception I think, is for testing/development both on kernel code 
and other libraries that you already have code running on top of. For 
example, maybe I am hacking at the virtual dom code, or maybe I have my own 
package that handles authentication that I want to make some changes too 
but test an application against.

In the virtual dom kernel code case, I cannot publish that package, so how 
to run my experimental changes?
In the auth case, I have not completed and tested my changes, so I should 
not publish a new version of my package.

It is very handy to be able to substitute a package in the build to do 
this. I use elm-install to accomplish this, so its not a problem being 
absent from the official tool. But I don't think it would be a bad feature 
to have in the official tool, and the safeguard of not being able to 
publish native, effect or port modules to the package repo is there to make 
it a safe feature.

-- 
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: Looking for pretty printers written in Elm?

2017-07-03 Thread 'Rupert Smith' via Elm Discuss
On Monday, July 3, 2017 at 6:17:22 PM UTC+1, Max Goldstein wrote:
>
> Can you please tell us more about what you are trying to pretty print 
> (JSON?) and why (restraints, assumptions, etc)?


To begin with Java code, XML, Elm code. I do a lot of stuff with code 
generators and currently use something horrible called String Template. I 
want to move away from that and am considering using Elm, or perhaps Frege 
or the other Haskell on JVM implementation, or Haskell, Ocaml. Doesn't need 
to be too sophisticated to start with, indentation and long line breaking.

-- 
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] Looking for pretty printers written in Elm?

2017-07-03 Thread 'Rupert Smith' via Elm Discuss
There is this one, which I would need to upgrade from 0.17:

http://package.elm-lang.org/packages/vilterp/elm-pretty-print/1.0.1

Any others?

-- 
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] any editor supports elm simple whole-buffer reformat?

2017-07-03 Thread 'Rupert Smith' via Elm Discuss
On Monday, July 3, 2017 at 7:55:41 AM UTC+1, Zachary Kessin wrote:
>
> I have found elm and emacs work just fine it just takes some fine tuning
>

Care to share some of your emacs configuration? 

-- 
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: How to manage long running computations in Elm?

2017-07-02 Thread 'Rupert Smith' via Elm Discuss
On Friday, June 30, 2017 at 9:43:51 AM UTC+1, Jakub Hampl wrote:
>
> One way of approaching this is to show the user progress in an interesting 
> way. In this example 
> , the 
> computation that calculates the final layout of a network graph (which is 
> pretty expensive) is animated so the user can watch the algorithm converge.
>

Nice example, I like how you can interrupt it by clicking on one of the 
other examples, so the UI is not getting frozen.

One thing about this example, is that is driven off of a timer tick. So if 
each iteration of the node layout takes say one microsecond of CPU time, 
and the timer ticks every millisecond - it will only use 1/1000th of the 
CPU. Its fine for animation.

In my case I don't want to use a timer tick to drive the computation, 
because I want to use 100% of the CPU (or close to it) to complete a 
computation as quickly as possible, but still not block user interaction.

We had a good first Elm Scotland Meetup btw, hope you can make the next one.

-- 
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] any editor supports elm simple whole-buffer reformat?

2017-07-02 Thread 'Rupert Smith' via Elm Discuss
On Saturday, July 1, 2017 at 1:33:04 AM UTC+1, Raoul Duke wrote:
>
> Thanks! I did do that. Did sorta get it working in emacs mode! But 
> overall it didn't / doesn't seem to work so well, as I said -- wonky 
> UX. Now hoping for something that really just works out of the box 
> w/out any extra config at all?
>

I am also a fan of Emacs, but have not had much joy with Emacs and Elm. 
Probably we are in a minority liking both Emacs and Elm.

Try Atom + elmjitsu + elm-format. 

-- 
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: elm-mdl only one dialog per application?

2017-07-02 Thread 'Rupert Smith' via Elm Discuss
On Saturday, July 1, 2017 at 11:06:58 PM UTC+1, Christopher Roe wrote:
>
> Just in case this conversation is still active .. and following on from 
> OverMind's suggestion that the Dialog interface be redrawn to match the 
> current need for user input via a dialog ... If I have 2 buttons visible on 
> the screen at the same time, how can I tell which button was pressed when 
> rendering the dialog?  There does not seem to be any opportunity to update 
> the model... or is there?  It feels like I should open the dialog via 
> something like  a command on the back of handling a message in update.  
>

Buttons are distinguished by passing different values for the Index 
parameter to Button.render:

http://package.elm-lang.org/packages/debois/elm-mdl/8.1.0/Material-Button#render

Then to create a Cmd that is triggered when the button is clicked, use 
Button.onClick, with some Msg type that you have created to receive these 
events.

For multiple dialogs, you'd use different Index parameters and .onClick 
events. Hope that makes sense?

-- 
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: elmq - is it a worthwhile abstraction or not?

2017-06-21 Thread 'Rupert Smith' via Elm Discuss
On Monday, June 19, 2017 at 11:15:26 PM UTC+1, Rupert Smith wrote:
>
> On Friday, June 16, 2017 at 5:27:37 PM UTC+1, Mark Hamburg wrote:
>>
>> All that said, I think elmq is really interesting for the case where the 
>> interaction isn't hierarchical.
>>
>
> Yes. In my case I have the Auth module, and other modules using it, which 
> are typically structured like this:
>
> Main
>  - Auth
>  - Other
>

I've now refactored my auth package to not use elmq, but instead have an 
API that is purely specific to what it does. There was no need to have 
message routing that can be runtime dynamic.

It is split into 2 public modules:

Auth - which provides the API most of an application wants to interact 
with. To login, logout etc, and to query a sub-set of the total auth state 
to know what is the current username, what are the current permissions, and 
so on. The remainder of the auth state is fully opaque so that applications 
do not depend on it and the auth package can continue to evolve whilst 
presenting a consistent public API.
AuthController - which is TEA structured. It has an update function which 
accepts the login, logout etc "commands" to update the state. I say 
"commands" in inverted commas because they are not of type Cmd Msg, but of 
type AuthCmd, which is an extra thing any update function requested a 
side-effect on the auth state will return.  This part gets wired in to the 
Elm update cycle of whatever application is consuming the auth package. If 
I need some helper functions to reduce boilerplate that this wiring in will 
entail, they will go in their too.

I still like the idea of a more general purpose 'messaging middleware' for 
Elm, but this just feels simpler and more direct.

I will also now be able to publish it along with the back-end auth 
micro-service, and also an elm-mdl UI for managing accounts, roles, 
permissions etc.

-- 
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: elmq - is it a worthwhile abstraction or not?

2017-06-19 Thread 'Rupert Smith' via Elm Discuss
On Friday, June 16, 2017 at 5:27:37 PM UTC+1, Mark Hamburg wrote:
>
> All that said, I think elmq is really interesting for the case where the 
> interaction isn't hierarchical.
>

Yes. In my case I have the Auth module, and other modules using it, which 
are typically structured like this:

Main
 - Auth
 - Other

So I am using it to talk more directly from Other -> Auth. Sibling rather 
than parent-child communication. But I came to the realization that the 
parent-child part is still there because Cmd.map and Sub.map are still used 
to plug everything together.

I think it was interesting to try this approach, and it was a quick way to 
get started when I was unsure of that the Auth API would look like. Now 
that I know that Other needs to be able to request 'login', 'logout', 
'refresh' or 'unuathed' as a side-effect, or to take the current auth state 
providing 'isAuthed', 'permissions' and so on as inputs, I may as well just 
code that API directly, and move away from a more generic approach.

-- 
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: elmq - is it a worthwhile abstraction or not?

2017-06-16 Thread 'Rupert Smith' via Elm Discuss
On Friday, June 16, 2017 at 12:04:48 PM UTC+1, Rupert Smith wrote:
>
> As above, make my own ElmqMessage type and pull the routing logic out of 
> the effects module. This would result in a message router that retains the 
> dynamic routing capability, should anyone ever need such a thing.
>

This would actually be better - one of the problems elmq has is that the 
internal representations of Cmd and Sub in an effects module need to be 
declared in it as a particular concrete type:

https://github.com/rupertlssmith/elmq/blob/master/src/Elmq.elm#L2

As the consumer of the module cannot vary this type with type parameters, 
it settles on passing everything as a Json.Encode.Value. This means that 
the message router is not as strongly typed as it could be - the compiler 
cannot make sure that when I pass a chat message of type String, the 
receiver of that message is also  expecting a String and not say an Int.

Doing it all outside of an effects module with a type of 'ElmqMessage a' 
would allow stronger guarantees to be enforced.

-- 
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] elmq - is it a worthwhile abstraction or not?

2017-06-16 Thread 'Rupert Smith' via Elm Discuss
By writing this post, I may answer my own question, but anyway your 
opinions appreciated as always.

=== What is it?

As I have posted on here before, I pulled this library:

https://github.com/rupertlssmith/elmq

Out of the elm-ui code here:

https://github.com/gdotdesign/elm-ui

The idea is that if you have nested update functions in several modules:

Main.update
  Child1.update
  Child2.update
  ..

And you also have nested subscriptions:

Main.subscription
  ChildA.subscription
  ChildB.subscription
  ..

Where the 2 sets (1..n) and (A.._), may have an intersection. The elmq 
library provides a convenient way for the child modules to talk to one 
another, based on using named 'channels'.  Here is a little example:

module Child1 exposing (..)

import Elmq

-- To send string messages to the "chat.elm" channel.
elmTalk : String -> Cmd msg
elmTalk message =
Elmq.sendString "chat.elm" message

module ChildA exposing (..)

-- To receive string message on the "chat.elm" channel
type Msg =
ReceiveChat String

subscriptions : Model -> Sub Msg
subscriptions model =
Elmq.listenString "chat.elm" ReceiveChat

It is implemented as an effects module; there is a little routing engine 
that processes the Cmds and turns them into Subs, where matching senders 
and listeners on the same channel.

=== Why?

Very early on in my learning with Elm, I did not know what an 'out message' 
is. People tried to point me in this direction, I was confused and there 
was just too much to get my head around.

I pulled out the auth code from an application I wrote, and wanted to 
re-use it. It is very convenient to be able to easily invoke 'unauthed : 
Cmd msg' from anywhere in an application without having to worry about a 
specific out message type, and having to implement the routing logic for 
the auth out messages in the Main.update of every application I write 
seemed like it would be a pain. I just wanted to encapsulate auth as a 
re-usable thing that I can drop into any application I write.

Working with something with the type 'Cmd msg' seems easier than working 
with an extra out message type, since update functions tend to return Cmds 
anyway.

Out message are considered a little awkward in Elm - we often feel we are 
having to write a lot of boiler plate to pass them up the chained update 
functions.

== What are the potential benefits?

There is a generic message router - that logic does not need to be 
re-implemented in every Main.update, I ever write.

The concept of channels can be useful for more dynamic routing. Channels 
can come and go. This feature may actually prove to be useful, but I don't 
actually have an application that needs it.

== Why reconsider it?

Now that I sat through Richard Feldman's talk, I know that even the generic 
concept of 'out messages' can be too wide. If you have a nested update 
function that needs to return something, just return it. If it needs to 
return lots of things, those things may get enumerated as a tagged union - 
or the design might be wrong.

Elmq does not really solve the boilerplate issue that nested update and 
subscriptions present. For example in my Main.update I am still using 
Cmd.map to lift child messages to the main Msg type, and in 
Main.subscription I am still Sub.map to forward the subscriptions to child 
modules. This made me realise that all I am really doing with elmq is 
hacking Cmd and Sub to work as a generic out message types - I may as well 
just declare my own ElmqMessage type, pull the routing logic out of the 
effects module and run it in the application instead.

I can't publish effects modules. Using elmq means I can't publish other 
things I have done that depend on it.

== How to fix my code?

As above, make my own ElmqMessage type and pull the routing logic out of 
the effects module. This would result in a message router that retains the 
dynamic routing capability, should anyone ever need such a thing.

Narrow the types of the auth messages that my applications need - that is, 
don't use my own generic ElmqMessage type, just narrow it to the specific 
things that auth needs - type AuthMsg = LogIn | LogOut | Refresh | 
Unauthed. Have the auth module expose an update function that is specific 
to this type, update : AuthMsg -> AuthState -> AuthState.

Get back within the Elm 0.18 platform, and be able to share my wondrous 
projects with you all. Thanks for reading, if you get this far.

-- 
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] Add css classes to existing html nodes

2017-06-15 Thread 'Rupert Smith' via Elm Discuss
On Monday, June 12, 2017 at 8:03:41 AM UTC+1, Pi wrote:
>
> Hi Eike!
> Have you had a look at the package pablohirafuji/elm-markdown? It's a pure 
> Elm implementation of a Markdown parser where you can customize how HTML 
> gets rendered.
> See https://github.com/pablohirafuji/elm-markdown#customization. 
> I'm not sure whether the lib supports tables at all since they aren't 
> mentioned anywhere in the docs.
>

I'll have to try that. I notice that the evanc/elm-markdown package 
produces runtime errors sometimes if the markdown is malformed - it wraps 
some js library and I get the impression it was just a quick hack to get 
something working. The pure elm one, especially with greater customization 
is a lot more appealing. 

-- 
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: How to manage long running computations in Elm?

2017-06-13 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, June 13, 2017 at 4:10:15 AM UTC+1, Matthieu Pizenberg wrote:
>
> On Wednesday, June 7, 2017 at 4:08:37 PM UTC+8, Rupert Smith wrote:
>>
>> On Tuesday, June 6, 2017 at 3:20:42 PM UTC+1, Rupert Smith wrote:
>>>
>>> The problem with long running computations in a single threaded UI is 
>>> that they may cause the UI to block and become unresponsive for a period. 
>>> Definitely not an acceptable user experience.
>>>
>>
> Yep, totally agree with you. I also would love to be able to run some 
> scientific computation, but the UI blocking is a stopper. 
>

But you can split the computation at some suitable point, returning a 
continuation to 'calculate the rest later', then return to your 'update' 
function and have it return a Cmd to come back in later and continue the 
work. Did you try this technique? Its not ideal, but at least it makes it 
no longer a stopper.

-- 
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: How to manage long running computations in Elm?

2017-06-13 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, June 13, 2017 at 4:26:33 PM UTC+1, Vlad GURDIGA wrote:
>
> One thing that I think I would have tried in this case, it to delegate the 
> long running computation to a webworker 
> , and then talk with it through 
> a port.
>

Yes, and I see Richard Feldman has had an experiment with Elm and 
webworkers:

https://github.com/rtfeldman/elm-web-workers 

Its for Elm 0.17 so I guess just an experiment, but worth a look.

-- 
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: Status update and multiple application servers

2017-06-10 Thread 'Rupert Smith' via Elm Discuss
On Friday, June 9, 2017 at 5:18:35 AM UTC+1, machinelea...@gmail.com wrote:
>
> Sorry I'm only a beginner and I need to understand this thing at the level 
> of software architecture. 
>
> If I'm not wrong, status management (or more generally application logic) 
> is implemented in Elm on server side (as opposite to other JavaScript 
> frameworks running on client side). 
>
> Then how is status consistency guaranteed in a professional enterprise 
> environment, in case of load balancing, multiple application servers, 
> etc... What if the previous message hits a server and the next another one?


The concept of a 'single point of truth' comes into play here. 

For some given piece of data, there needs to be just one place in your 
architecture that holds the definitive state of that piece of data. 

Some examples of how this can be achieved:

* A database that is shared across the application servers.
* Sessions that are serializable and can be moved to whichever application 
server processes the request. Some kind of fast distributed store may be 
used for this purpose.
* Sticky sessions. The same sessions always comes back to the same server, 
making it simpler to guarantee a single point of truth.

-- 
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: How to manage long running computations in Elm?

2017-06-07 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, June 6, 2017 at 3:20:42 PM UTC+1, Rupert Smith wrote:
>
> The problem with long running computations in a single threaded UI is that 
> they may cause the UI to block and become unresponsive for a period. 
> Definitely not an acceptable user experience.
>
> I have created a library for helping with AI-type searches. This provides 
> a 'next' function that steps the search along by examining a single 'node' 
> in the search space. The search space forms a graph, and as each node is 
> de-queued from the search buffer, it is checked to see if it is a goal 
> state, and all its successor states are created from a user supplied 'step' 
> function, and en-queued onto the search buffer.
>

I should add, it seems likely any long-running process will be structured 
to have a loop at the top-level. This loop can be turned into a 
continuation '() -> More a', to break the task down into steps. So this 
does not just apply to my AI search library but any longer computation we 
might want to do that puts too much delay into the UI update cycle.

-- 
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 manage long running computations in Elm?

2017-06-06 Thread 'Rupert Smith' via Elm Discuss
The problem with long running computations in a single threaded UI is that 
they may cause the UI to block and become unresponsive for a period. 
Definitely not an acceptable user experience.

I have created a library for helping with AI-type searches. This provides a 
'next' function that steps the search along by examining a single 'node' in 
the search space. The search space forms a graph, and as each node is 
de-queued from the search buffer, it is checked to see if it is a goal 
state, and all its successor states are created from a user supplied 'step' 
function, and en-queued onto the search buffer.

http://package.elm-lang.org/packages/the-sett/ai-search/3.1.0/Search#next

next : SearchResult state -> SearchResult state

type SearchResult state
= Complete
| Goal state (() -> SearchResult state)
| Ongoing state (() -> SearchResult state)

So I can run just 1 or perhaps a few hundred iterations of the search in 
each loop around the Elm 'update' function. I can return a Cmd that will 
use the cause the () -> continuation to run some more iterations next time, 
and that will also give control back to the Elm kernel to process other 
Cmds and keep the UI responsive.

Its explicit time-slicing of the CPU in application code, which is not so 
nice.

Ideally, I would have a background thread running the search. On every 
iteration it would check a volatile (shared memory) flag in case the user 
got bored waiting for the results and clicked cancel. 

I know there have been a few experiments in hooking up Elm with webworker 
threads. Has anyone tried this out? In particular was there a way to do 
inter-process communication, specifically the cancel flag I described above?

There is some IPC stuff mentioned under 'Future Plans' (spawn/kill/send) in 
the Process module:

http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Process

Could this be implemented on top of webworker threads?

-- 
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: Force directed graph drawing in Elm

2017-05-29 Thread 'Rupert Smith' via Elm Discuss
On Sunday, May 28, 2017 at 1:03:05 PM UTC+1, Jan Hrček wrote:
>
> Would some of you find such library useful? If so what functionality it 
> should provide?
>
> My idea for the functionality provided by the library would be this:
>
> What you provide: 
> - a graph with some data (probably based on elm-community/graph)
> - parameters of the layout algorithms (similar to what you see in the 
> prototype)
> - node and edge rendering function (something returning Svg elements for 
> rendering nodes and edges, given (x,y) coordinates of the nodes)
>
> What library would do for you: 
> - it would enrich the graph by adding "node position" information and 
> would simulate how these positions change over time
>

I think you pretty much captured how I would imagine it would work as a 
library. The simulations of how positions change over time might work by 
providing a subscription in a similar manner to how 
'mdgriffith/elm-style-animation' works?

http://package.elm-lang.org/packages/mdgriffith/elm-style-animation/latest/

By chance, I am also working on graph layouts at the moment. A force 
directed layout might be useful to me. Unfortunately it won't do exactly 
what I need, but I might be able to make use of it to do an approximate 
initial layout, or to optimize a layout that I have produced by other 
methods. The approach I am taking to laying out my diagrams is going to be 
based on searching for solutions based an heuristics like number of links 
crossing, length of the links, number of corners in links and so on. The 
diagrams I am working with are like entity-relationship diagrams - with 
boxes and links between them.

>

-- 
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: Implementing websocket-based protocol - lessons learned

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 23, 2017 at 3:30:44 PM UTC+1, Christophe de Vienne wrote:
>
> It is what I did at first, but it has serious drawbacks. The biggest was 
> that a subscription implies an update of the Nats state... so I had to 
> push the state to all the update functions and they had to sent it 
> back... Very messy. 
>

This use case can be catered for by using a correlation id, I think. Also, 
perhaps the word 'subscription' is getting overloaded here, you have the 
Elm Sub(scription), and the NATS protocol subscription, and the middleware 
subscription (listen), making this conversation a little difficult to nail 
down...

== Module Consuming the NATS Protocol

Elmq.sendString "subscribe" "nats0"
Elmq.listen "nats0"

== The module implementing the NATS protocol

type Msg =
NewNatsSubscription String
| ...

Elmq.listenString "subscribe" (\channel -> NewNatsSubscription)
Elm.send channelName ...

==

So I sent a subscription request to Nats, and when Nats processed it, it 
sends back messages on the named channel. The channel name is used as a 
correlation id to link together the act of creating the subscription and 
the messages that then flow over that subscription.

I don't know the specific of NATS and whether it has named channels etc. 
but hopefully you get what I am on about?

-- 
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: Best practices to create examples for an elm package?

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Monday, May 8, 2017 at 3:38:55 PM UTC+1, Eirik Sletteberg wrote:
>
> Maybe write an example in the form of an integration test - then you know 
> your example will be up to date with the actual code, and it may even 
> discover bugs!


I think there is an issue here that did not come up for discussion yet:

Suppose I have some examples or some tests, and those need packages that 
the actual library does not use. Those packages get sucked in as 
dependencies even though the library itself does not use them?

Is there a way to have tests or examples and for those to use extra 
packages, but for those packages not to be included as transitive 
dependencies of the library itself? 

-- 
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: Implementing websocket-based protocol - lessons learned

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 23, 2017 at 3:04:01 PM UTC+1, Christophe de Vienne wrote:
>
> A discussion around a concept of "middleware", able to define its own 
> Cmd and Sub that it could rewrite along with updating its own state 
> (which can be a part of the app model), would be interesting. 
>
> Cmd and Sub are pretty opaque beasts from where I stand, may be we can 
> already do such a thing. 
>

There are modules that build their own subscriptions, for example:

http://package.elm-lang.org/packages/mdgriffith/elm-style-animation/3.5.5/Animation

provides a function to build a subscription. This is just a convenience 
function; under the covers the animations are being iterated as a timer 
ticks, so the real Sub being created is a timer one.

So I think if you can define what flexible 'command' and 'subscription' 
constructor functions you think the middleware needs, and we can try and 
map those down to the simplest Cmd and Sub implementations that cover all 
the needed use cases, then that gives us what we would need to implement in 
an effects module. Essentially, it would be a messaging kernel that is 
flexible enough that any reasonable messaging application you like can be 
built on top of it.

I once had a great job, which was to be paid to work on an open source 
implementation of the AMQP protocol (Apache Qpid). In Java land the 
messaging API is called JMS, and it is just what I described above - a 
messaging API (and implied kernel) that is generic enough to fit most 
reasonable middleware needs and implementations.

-- 
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: Implementing websocket-based protocol - lessons learned

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 23, 2017 at 3:06:29 PM UTC+1, Rupert Smith wrote:
>
> There was someone else who wrote a 'middleware' component for Elm, but did 
> it with 'out messages' instead of as an effect module. There was a routing 
> part that you put in you top-level update function. Let me see if I can 
> find it...
>

This:

https://groups.google.com/forum/#!searchin/elm-discuss/messaging%7Csort:relevance/elm-discuss/gSkvCgTj4q0/TJJCtcX9BgAJ

https://github.com/RJWoodhead/elm-memo 

-- 
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: Implementing websocket-based protocol - lessons learned

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 23, 2017 at 2:50:05 PM UTC+1, Rupert Smith wrote:
>
> I'm going to the upcoming Elm Europe conference, so I can talk to the core 
> devs there and see what they think of it. As I said before, perhaps its not 
> an 'architectural' direction that they like; on the other hand it does seem 
> both simple and useful.
>

There was someone else who wrote a 'middleware' component for Elm, but did 
it with 'out messages' instead of as an effect module. There was a routing 
part that you put in you top-level update function. Let me see if I can 
find it...

One criticism of elmq might be that it is not so transparent. So if a 
module sends a message, the Cmd for that is passed into the Elm kernel, and 
from then on it sort of disappears from the compilers view - the messages 
are untyped in so far as that they are Json.Encode.Values. There is no way 
for the compiler to check that whatever receives them has a matching type, 
or indeed that there is any receiver listening at all. At least with 'out 
messages' the type checking will flow across the modules. Of course there 
could still be a bug in code where the 'out messages' are ignored and not 
processed. It may be possible to improve the elmq API to mitigate these 
issues - for example, an option to discard messages when there is no 
receiver and so on.

-- 
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: Implementing websocket-based protocol - lessons learned

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Monday, May 22, 2017 at 4:08:13 PM UTC+1, Christophe de Vienne wrote:
>
> I should have had a better look at what elmq allowed indeed. 
>
> That said until elmq (or something equivalent) is published on 
> package.elm-lang.org, we get a non-publishable package. 
>

Yes, it would make your package non-publishable too.
 

> I will make some tests with now that the plain version is working 
> properly. 
>

Would be interesting to see if elmq has enough features to support your use 
case, or if it needs some extension. I think gathering use cases, reviewing 
what other language do and so on is the work that needs to be done prior to 
proposing adding it as a supported effects module. Also, nice that you did 
it without an effects module, as that is one more example to compare the 
code with/without elmq, if you were to redo it on top of elmq.

I'm going to the upcoming Elm Europe conference, so I can talk to the core 
devs there and see what they think of it. As I said before, perhaps its not 
an 'architectural' direction that they like; on the other hand it does seem 
both simple and useful.

-- 
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] Idris holes - Thoughts for Elm?

2017-05-23 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 23, 2017 at 6:45:20 AM UTC+1, Aaron VonderHaar wrote:
>
> 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")
>

Elmjutsu is also already making use of 'type holes' to infer types, but it 
is hacked without explicit support from the compiler:

https://atom.io/packages/elmjutsu#infer-type
http://blog.jenkster.com/2016/11/type-bombs-in-elm.html 

Some improved compiler support certainly wouldn't hurt.

-- 
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: Implementing a protocol on top of WebSocket: should I build a effect module ?

2017-05-18 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, May 17, 2017 at 5:02:55 PM UTC+1, Christophe de Vienne wrote:
>
> The main thing that bothers me is that I will need to pass the 
> Nats.State to every update function because subscribing requires an 
> update of the state... And I see no way to avoid that except using an 
> effect module. 
>

So you would rather that your Nats module kept its own state 'private' and 
lets users of it send it a message asking to subscribe?

Suppose your code has 3 update functions and is structured like this:

Main (top-level update)
 - Nats (updates Nats State as websocket conversation progresses)
 - MyFunkyApp (does something cool. Needs to subscribe to Nats)

The TEA pattern that you could use to do this, whilst keeping the Nats 
state private, is to use an 'out message' from MyFunkyApp. Then have some 
routing in Main, that passes the subscriptions requests to Nats, where Nats 
can update its State in private.

It can be a lot of boilerplate if you have lots of modules using Nats, so I 
can see why the effects module approach is appealing.

===

I was eating breakfast this morning when it occurred to me that I may have 
a solution for you; it is an effects module:

https://github.com/rupertlssmith/elmq

If we divide your Nats implementation into two independant (orthogonal) 
parts - there is the websockets part, and there is a part relating to how 
you plumb this re-usable protocol module into an Elm application. The 
'elmq' effects module could solve the second part for you. This would mean 
that you don't need to write your own effects module for this specific 
problem as the concept has already been captured by the elmq effects module.

===

Here is an example of using elmq. Authentication is a very common component 
of applications and I also felt that it was likely that many modules in my 
applications would need to interact with authentication. In particular, I 
have quite a few Json web services over HTTP - at any time one of them may 
get back a 403 or a 401 and will then need to update the auth state to say 
that we are not currently authenticated.

To avoid all the 'out message' plumbing that would require, I built my auth 
module on top of elmq.

It provides an API, that stuffs event messages onto elmq channels:

https://github.com/rupertlssmith/elm-auth/blob/master/src/Auth.elm

And the AuthController is then able to subscribe to these messages, and 
privately update its state:

https://github.com/rupertlssmith/elm-auth/blob/master/src/AuthController.elm#L228

So you can see, it is very easy for a module to import the Auth API and use 
it, without having to worry about the plumbing needed to update the 
authentication state.

===

The elmq module was lifted from original code here: 
https://github.com/gdotdesign/elm-ui

One limitation of it is that you can only pass the primitive types or a 
Json.Encode.Value. Anything else you must provide an Encoder/Decoder for.

See the readme for elmq for some discussion points around how its API could 
be evolved. I would be very interested to hear if you think your use case 
fits it, or if you think it needs adapted a little to cater for your need? 
Would also be very happy to take suggestions on board and improve it.

It is not an official effects module, so you must install it with 
elm-github-install.

If it is useful to you, it might be time to consider making a proposal on 
elm-dev to push it towards becoming an official effects module. I have 
considered this before, but was not sure if it would be well received or 
not - its certainly quite a different way of doing things to the TEA 
approach. Also as Elm is single threaded, and this is really an 
asynchronous messaging model (like JMS for Java), does it make sense as a 
programming model for Elm? On the other hand, its very useful, so why not.


-- 
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: What heap implementations exist for Elm?

2017-05-17 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, May 17, 2017 at 3:57:44 PM UTC+1, Rupert Smith wrote:
>
> On Wednesday, May 17, 2017 at 11:40:35 AM UTC+1, Rupert Smith wrote:
>>
>> http://package.elm-lang.org/packages/TSFoster/elm-heap/latest
>>
>
> Bugger. This heap implementation does not allow and arbitrary comparison 
> function. It has this:
>
>  by : (a -> comparable) -> Options b -> Options a
>
> But that requires a mapping from the type being compares onto comparable.
>
> If there is an implementation that lets me use a comparison function of 
> type 'a -> a -> Order', that would be better.
>

But internally it does use an 'a -> a -> Order':

type Options a
= Options
{ order : SortOrder
, compare : a -> a -> Order
}

Which it builds by converting an 'a -> comparable' function:

makeCompare : (a -> comparable) -> (a -> a -> Order)
makeCompare fn a b =
Basics.compare (fn a) (fn b)

Perhaps the author meant to expose Options(..) so users can build their own 
compare function?

-- 
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: What heap implementations exist for Elm?

2017-05-17 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, May 17, 2017 at 11:40:35 AM UTC+1, Rupert Smith wrote:
>
> http://package.elm-lang.org/packages/TSFoster/elm-heap/latest
>

Bugger. This heap implementation does not allow and arbitrary comparison 
function. It has this:

 by : (a -> comparable) -> Options b -> Options a

But that requires a mapping from the type being compares onto comparable.

If there is an implementation that lets me use a comparison function of 
type 'a -> a -> Order', that would be better.

-- 
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 heap implementations exist for Elm?

2017-05-17 Thread 'Rupert Smith' via Elm Discuss
I need a heap where I can supply my own ordering function:

ordering : a -> a -> Order

And be able to take the smallest item from the heap:

Heap.least : Heap a -> a

There is this one:

http://package.elm-lang.org/packages/TSFoster/elm-heap/latest

Any others?

-- 
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] Platform.Cmd.batch executes commands in reverse order

2017-05-12 Thread 'Rupert Smith' via Elm Discuss
On Friday, May 12, 2017 at 4:53:19 PM UTC+1, Peter Damoc wrote:
>
> The execution of a Cmd.batch list of commands has not ordering guarantee. 
>

I suspect that whilst there is no ordering guarantee given, the actual 
implementation probably does a 'foldr' executing them in reverse order. 
This behavior seems very consistent.

In theory they could be executed in parallel and non-deterministically. In 
reality its javascript on the browser, which is single threaded, so there 
is no concurrency.

-- 
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: Linear algebra for 2d geometry?

2017-05-12 Thread 'Rupert Smith' via Elm Discuss
On Thursday, May 11, 2017 at 7:00:06 PM UTC+1, Ian Mackenzie wrote:
>
> I also cloned OpenSolid/svg and made a version that renders to 
>> elm-community/typed-svg. Once I have finished converting the docs, tests 
>> and examples you might like to clone it back again and publish it under 
>> OpenSolid/typed-svg? I'll let you know once I get to that stage anyway.
>>
>
> I confess I'm still not sure exactly why a separate typed-svg version is 
> necessary...since the TypedSvg.Core.Svg and TypedSvg.Core.Attribute are 
> still just aliases for VirtualDom.Node and VirtualDom.Property 
> respectively (instead of being new opaque types or something), you can 
> already mix typed-svg and opensolid/svg elements/attributes freely 
> without any kind of conversion or anything - see 
> https://ellie-app.com/39pwNnwDzcqa1/2 for an example.
>

Thanks for pointing that out. I swapped my code over to opensolid/svg  and 
it all compiled and runs fine. In which case, perhaps the thing to do might 
be for me to create a little pull request adding a statement and short 
example to the docs for opensolid/svg to explain that it also works with 
typed-svg.

-- 
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: How would you code a search in Elm?

2017-05-11 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, May 10, 2017 at 5:07:29 PM UTC+1, Rupert Smith wrote:
>
> By search, I mean a backtracking search over a 'graph' of possibilities.
>
> There is a well-known pretty printing library by Joh Hughes. It is for 
> Haskell but can be made to work on ML style languages by introducing some 
> laziness explicitly. Haskell is lazy by default, which is why it is not 
> needed there.
>
> http://belle.sourceforge.net/doc/hughes95design.pdf
>
> It defines lambdas that evaluate to the various possible choices then only 
> evaluates the 'best' choice according to a heuristic for evaluating pretty 
> printing possibilities. I think when a bad choice deeper down is uncovered, 
> it can backtrack? To be honest, I never really analysed the code and fully 
> understood it, just made use of it or blindly ported it to ML.
>
> Is there some library for Elm that helps with coding this kind of search? 
> Or a simpler example illustrating the technique?
>
> I am trying to do a 2d layout algorithm, and thinking of some heuristic 
> that will choose amongst various layouts, trying simpler and more symmetric 
> options first.
>

I found this pretty printer which is desinged by Philip Wadler and builds 
on the Hughes pretty printer:

http://package.elm-lang.org/packages/vilterp/elm-pretty-print/latest

But this code looks optimised and I don't see how to pull out a re-usable 
back tracking search from it. So I think perhaps the Hughes design will be 
better to take as a starting point. In the paper he describes "Monads for 
Backtracking" which sounds like what I am after.

I think I will try and implement a search that solves a 9-puzzle (you know 
with 8 tiles and a hole and you slide the tiles about to make a picture), 
using the 'Manhattan heuristic'. Easy problem to understand as an example 
of a heuristic search in order to figure out how to implement a 
back-tracking search and discover what code might be re-usable across 
different search problems.

Quiet round here, ever since Noah told you all to behave yourselves. :-P

-- 
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: Local third-party packages

2017-05-09 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 9, 2017 at 8:36:37 AM UTC+1, Gusztáv Szikszai wrote:
>
> I'm glad it worked :) I need to figure out something for the install 
> problem though, probably will find an other place where the binary can be 
> stored.
>

Its strange that when running "npm install -g elm-github-install" as root, 
it cannot create a directory under /root/, as the root user would 
definitely have the rights to do that. I don't really understand what is 
wrong with it.

I would expect though, when installing with -g, that it gets installed 
under "/usr/local/lib/node_modules/".

-- 
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: Linear algebra for 2d geometry?

2017-05-09 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, May 9, 2017 at 2:46:06 AM UTC+1, Ian Mackenzie wrote:
>
> In general, yes, using matrices would likely be a bit more efficient, but 
> you can get pretty close using techniques like the above, and I think the 
> expressiveness/clarity/flexibility is better. 
>

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 
also concede that there is no guarantee that using 3x3 matrices would be 
faster anyway, it depends on the implementation and the only real way to 
know would be to set up a benchmark and measure and compare.

So I decided to go with OpenSolid as it is a very nice library and has a 
lot of features.

I also cloned OpenSolid/svg and made a version that renders to 
elm-community/typed-svg. Once I have finished converting the docs, tests 
and examples you might like to clone it back again and publish it under 
OpenSolid/typed-svg? I'll let you know once I get to that stage anyway.

-- 
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: Local third-party packages

2017-05-08 Thread 'Rupert Smith' via Elm Discuss
On Monday, May 8, 2017 at 8:39:57 PM UTC+1, Rupert Smith wrote:
>
> On Friday, May 5, 2017 at 11:52:09 AM UTC+1, Gusztáv Szikszai wrote:
>>
>> I've been working on this in the last few days, and published 1.0.0 
>>  
>> of *elm-github-install* which handles using a fork (or any other git 
>> repository for a package) and using a local directory. If anyone tries this 
>> out some feedback would be nice.
>>
>
> I forked another elm package and hacked it, and just want to be able to 
> reference it without tagging a release version or publishing. Will be a 
> very useful feature I think. I will try it out now, thanks.
>

Was able to work around the npm installer issue by installing as a ruby gem 
instead. Works nicely, and I was able to substitute a branch containing 
work in progress - many thanks for these additions to elm-install. :-) 

-- 
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: Local third-party packages

2017-05-08 Thread 'Rupert Smith' via Elm Discuss
On Monday, May 8, 2017 at 8:39:57 PM UTC+1, Rupert Smith wrote:
>
> On Friday, May 5, 2017 at 11:52:09 AM UTC+1, Gusztáv Szikszai wrote:
>>
>> I've been working on this in the last few days, and published 1.0.0 
>>  
>> of *elm-github-install* which handles using a fork (or any other git 
>> repository for a package) and using a local directory. If anyone tries this 
>> out some feedback would be nice.
>>
>
> I forked another elm package and hacked it, and just want to be able to 
> reference it without tagging a release version or publishing. Will be a 
> very useful feature I think. I will try it out now, thanks.
>

The installer seems to fail:

sudo npm install elm-github-install -g

> npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

> /usr/local/bin/elm-github-install -> 
/usr/local/lib/node_modules/elm-github-install/scripts/run.js

> /usr/local/bin/elm-install -> 
/usr/local/lib/node_modules/elm-github-install/scripts/run.js

> > elm-github-install@1.0.1 install 
/usr/local/lib/node_modules/elm-github-install

> > node scripts/install.js

> Downloading and extracting the binary from: 
https://github.com/gdotdesign/elm-github-install/releases/download/v1.0.1/elm-install-1.0.1-linux-x86_64.tar.gz

> events.js:163

>   throw er; // Unhandled 'error' event

>   ^

> Error: EACCES: permission denied, mkdir 
'/root/.elm-install/elm-install-1.0.1-linux-x86_64'

> npm ERR! Linux 3.16.0-4-amd64

> npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" 
"elm-github-install" "-g"

> npm ERR! node v7.10.0

> npm ERR! npm  v4.2.0

> npm ERR! code ELIFECYCLE
npm ERR! errno 1

-- 
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: Local third-party packages

2017-05-08 Thread 'Rupert Smith' via Elm Discuss
On Friday, May 5, 2017 at 11:52:09 AM UTC+1, Gusztáv Szikszai wrote:
>
> I've been working on this in the last few days, and published 1.0.0 
>  of 
> *elm-github-install* which handles using a fork (or any other git 
> repository for a package) and using a local directory. If anyone tries this 
> out some feedback would be nice.
>

I forked another elm package and hacked it, and just want to be able to 
reference it without tagging a release version or publishing. Will be a 
very useful feature I think. I will try it out now, 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: Linear algebra for 2d geometry?

2017-05-08 Thread 'Rupert Smith' via Elm Discuss
On Sunday, May 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.
>>>
>>
>> Ouch =) I've done lots of work with matrix-based libraries, and I've 
>> personally found matrices (and related stuff like quaternions) very 
>> powerful and flexible but also confusion- and error-prone. The OpenSolid 
>> libraries are my attempt to provide a better, more geometrically meaningful 
>> abstraction that still allows you to get good performance.
>>
>
> Sorry, my bad and thanks for the explanation. I guess I was a little 
> fixated on the matrix approach, but with your explanation it is clear that 
> your approach is at least as good.
>

There is potentially an advantage with matrices versus functions. A matrix 
could be thought of as a function, in the sense that its values capture a 
particular function that can be applied by multiplying by it. So you have 
captured the function as a lambda. Lambdas are opaque though, and when 
chained together to produce a new function, there is no way to guarantee 
that they will combine in such a way that they reduce to the simplest or 
most efficient representation; the compiler may do a good job though.

Suppose you have a complex chain of transformations like: scale, rotate, 
translate (requires 3x3 matrix for 2d work), mirror. Represent this with 
matrices M1, .., M4. The entire transformation can then be captured as a 
single matrix Mt = M1 . M2 . M3 . M4. As lambdas, my assumption is the 
compiler will not be smart enough to reduce it so neatly, and it will 
always be applied as 4 separate operations.

I guess you already know this... :-)

-- 
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: Linear algebra for 2d geometry?

2017-05-07 Thread 'Rupert Smith' via Elm Discuss
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.
>>
>
> Ouch =) I've done lots of work with matrix-based libraries, and I've 
> personally found matrices (and related stuff like quaternions) very 
> powerful and flexible but also confusion- and error-prone. The OpenSolid 
> libraries are my attempt to provide a better, more geometrically meaningful 
> abstraction that still allows you to get good performance.
>

Sorry, my bad and thanks for the explanation. I guess I was a little 
fixated on the matrix approach, but with your explanation it is clear that 
your approach is at least as good.

-- 
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: Linear algebra for 2d geometry?

2017-05-05 Thread 'Rupert Smith' via Elm Discuss
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 it a bit and it's awesome for what I understand you want.
>

This is nice and quite fully featured. 

It seems a shame that it is not Matrix based though. For example suppose I 
want to do a rotation of a shape, ultimately this comes down to mapping 
this vector rotation function over all points defining the shape:

rotateBy : Float -> Vector2d -> Vector2d
rotateBy angle =
let
cosine =
cos angle

sine =
sin angle
in
\(Vector2d ( x, y )) ->
Vector2d ( x * cosine - y * sine, y * cosine + x * sine )

Which means calculating sin and cos again for the same input values for 
each point.

If it was Matrix based, you'd calculate the rotation matrix once and then 
do just the matrix multiplication part for each point. Due to the 
properties of linear algebra, you can combine transformation matrices by 
multiplying them all together to capture a more complex transformation in a 
single operation.

So, nice library with lots of features, missed chance to work with a better 
abstraction.

-- 
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: Linear algebra for 2d geometry?

2017-05-04 Thread 'Rupert Smith' via Elm Discuss
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 it a bit and it's awesome for what I understand you want.
>

Thanks.

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. 

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


  1   2   3   4   5   6   >