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

2017-03-16 Thread Aaron VonderHaar
Note, however, that it is not difficult to implement the following, even
without circular references:

```
reader : Library -> Book -> Maybe Reader
borrowing : Library -> Reader -> List Book
checkOut : Reader -> Book -> Library -> Maybe Library
checkIn : Reader -> Book -> Library -> Library
```

On Thu, Mar 16, 2017 at 10:06 AM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> I am guessing the answer is no.
>
> type alias Reader { borrowing : List Book }
> type alias Book { reader : Maybe Reader }
>
> newBob = { bob | borrowing = [ warAndPeace ] }
> newWarAndPeace = { warAndPeace | reader = Just newBob }
>
> but the book that bob is borrowing will not have the link back to himself,
> as it was only added to the new version.
>
> Is the Elm heap therefore always cycle free?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


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

2017-03-16 Thread Joey Eremondi
Linear types aren't free, they come with conceptual difficulty, so I'd be
hesitant to use them as a default in Elm. As an advanced optimization maybe.

On Mar 16, 2017 4:34 PM,  wrote:

> > I'd wanted to take advantage of this a while back with an Elm->Rust
> compiler, that just used Rc (reference counting) for everything, so there's
> no garbage collection.
>
> I guess this is also interesting because (as I understand it) it's the
> lack of garbage collection in WebAssembly that disqualifies it as a compile
> target.  Might linear types be another approach?
> http://blog.tweag.io/posts/2017-03-13-linear-types.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


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

2017-03-16 Thread agjf . tucker
> I'd wanted to take advantage of this a while back with an Elm->Rust 
compiler, that just used Rc (reference counting) for everything, so there's 
no garbage collection.

I guess this is also interesting because (as I understand it) it's the lack 
of garbage collection in WebAssembly that disqualifies it as a compile 
target.  Might linear types be another approach? 
 http://blog.tweag.io/posts/2017-03-13-linear-types.html

-- 
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: Unit testing what else

2017-03-16 Thread Pedro Castilho
I believe Elm lends itself best to property-based testing 
 
of pure code rather than unit testing. Property-based testing can make 
stronger assertions than unit testing, as long as your code is pure (yet 
another reason for why you should keep the part of your code that interacts 
with the "real world" minimal)

In general, you do not need to test whether a constructor creates an item 
of a given type - that's what the type system is for (and a small part of 
the beauty of using a strongly-typed 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.


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

2017-03-16 Thread Joey Eremondi
Provided that everything's immutable, yes, this is the case. A proof of
this is

based on ordering of elements: when an element is created, it only refers
to things created before it. And since there's no mutability, it can only
ever refer things created before it. So no element ever refers to something
ahead of itself in the ordering, meaning that there's never a cycle.

This changes if you allow for mutable references (things like IORef in
Haskell), or if you're doing bad stuff in Native Code.

I'd wanted to take advantage of this a while back with an Elm->Rust
compiler, that just used Rc (reference counting) for everything, so there's
no garbage collection. But that's been put on hold.

On Thu, Mar 16, 2017 at 10:06 AM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> I am guessing the answer is no.
>
> type alias Reader { borrowing : List Book }
> type alias Book { reader : Maybe Reader }
>
> newBob = { bob | borrowing = [ warAndPeace ] }
> newWarAndPeace = { warAndPeace | reader = Just newBob }
>
> but the book that bob is borrowing will not have the link back to himself,
> as it was only added to the new version.
>
> Is the Elm heap therefore always cycle free?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


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

2017-03-16 Thread 'Rupert Smith' via Elm Discuss
I am guessing the answer is no.

type alias Reader { borrowing : List Book }
type alias Book { reader : Maybe Reader }

newBob = { bob | borrowing = [ warAndPeace ] }
newWarAndPeace = { warAndPeace | reader = Just newBob }

but the book that bob is borrowing will not have the link back to himself, 
as it was only added to the new version.

Is the Elm heap therefore always cycle free?


-- 
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] Publishing Elm package that depends on web components

2017-03-16 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, March 15, 2017 at 5:31:49 PM UTC, Peter Damoc wrote:
>
> I don't see why not. 
> Just make sure you document properly the running environment. 
>

Here is another example. This library needs the user to define a port and 
implement some javascript to hook it up. As it is well documented and there 
is no other way of doing it, its fine:

http://package.elm-lang.org/packages/abrykajlo/elm-scroll/latest

>

-- 
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] Request for idioms / announcement of a possible book

2017-03-16 Thread 'Rupert Smith' via Elm Discuss
On Thursday, March 16, 2017 at 2:15:23 PM UTC, Max Goldstein wrote:
>
> (Maybe is only special in that it's in core and imported by default.)
>

There is one other regard in which Maybe is special in Elm; you can pass 
Maybe through a port and there is a default mapping for it to a json 
'null'. In general, you cannot pass tagged unions through ports 
automatically.

-- 
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: Unit testing questions and TDD

2017-03-16 Thread Max Goldstein
I'm not aware of any really good examples of full webapp tests; maybe it's 
time to write some? That said,

Have you see strategies for effective testing 
? 
It's been updated a bit on master since the last release.

Is there a way to mock or leave out the location in this example or other 
> simplification?


You don't have to use Expect.equal, and you can write your own expectation 
functions using Expect.pass and Expect.fail. But it sounds like App.init 
needs a big record that you don't want to pass, but you want to call 
App.init. So you may need to refactor that function.

In another example, I want to check a view section that I pass the main 
> model to. I obviously don't want to set every property of the model so is 
> there another way?


Instead of

type alias Model = { foo : Foo, bar : Bar }

view : Model -> Html Msg
view { foo } = -- code that ignores bar

-- try

view : {a| foo : Foo} -> Html Msg
view { foo } = -- same code

This syntax means the view function accepts any record as long as it has 
the stated field. It can have extra fields, like Model, or not, like a test 
mock. As a bonus, this will make fuzz shrinking much more effective because 
only relevant fields will need to be shrunk.

Also, in that latter example is there an easy way to see if an html output 
> contains a particular string? 


elm-html-test  


-- 
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: Publishing Elm package that depends on web components

2017-03-16 Thread Ilias Van Peer
I actually found some prior art 
- http://package.elm-lang.org/packages/kkpoon/elm-echarts/latest


Op woensdag 15 maart 2017 18:11:12 UTC+1 schreef Jonas Schürmann:
>
> Hey folks,
>
> is it okay to publish a pure Elm package (no native code, no ports) that 
> depends on a custom element (web component) being defined by some other 
> Javascript library?
>

-- 
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] Request for idioms / announcement of a possible book

2017-03-16 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, March 15, 2017 at 11:06:19 PM UTC, Brian Marick wrote:
>
> I don’t quite understand what you’re saying. Do you have examples of how I 
> might go astray? Or how I’ve already gone astray in the available chapter 
> on Maybe? https://leanpub.com/outsidefp
>
> (Part of my confusion is that it seems to me that 
> maybe-is-a-data-structure is the way most programmers would reflexively 
> look at it. That is: “a functor is a wrapper”.)
>

Had a look and was encouraged to see a section headed "Maybe.map and 
pipelines of iffy computations" coming into it at about the earliest point 
you could bring up the topic. Although Maybe is a data structure, I think 
it makes sense to discuss its special role in computations that may fail 
ahead of discussing its use or not in the context of data modelling. 

The reason being that programmers coming from languages with 'null' are 
likely to first think of it as a substitute for null. And start creating 
records with Maybe fields in them - more helpful to save a discussion of 
the use of Maybe in data modelling (or not) for when you are ready to 
discuss how to make illegal states unrepresentable. 

I started out the wrong way on this, and had to unlearn and refactor my 
code. Now I think of Maybe as being more like a light-weight exception or 
an early return statement, when comparing with imperative code.


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