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

2017-03-21 Thread 'Rupert Smith' via Elm Discuss
On Monday, March 20, 2017 at 8:41:36 PM UTC, Martin Norbäck Olivers wrote:
>
>
> The reason I was thinking about it was not actually anything to do with 
>> garbage collection. I have a data modelling language with a type system, 
>> but it has grown in a slightly ad-hoc manner and needs some 
>> rationalization. I was wondering how well the type alias records + tagged 
>> unions + basic types part of Elm would suit my purposes. As the data models 
>> I build are often mapped onto relational database or mutable objects, I do 
>> need circular references to be possible.
>>
>
> I don't see the rationale for requiring circular references to map onto a 
> relational database though, they are referenced by key, not by pointer.
>

This is true. Its more for the object side of the mapping where both sides 
of a relationship may hold a reference to the other. Also for the data 
modelling side, where I want to be able to describe that 2 entities have a 
bi-directional relationship.
 

> Mutable objects can of course use circular references, and some algorithms 
> depend heavily on them, but they are a pain to handle for instance when 
> serializing. Which you do a lot in a web app.
>

Yes. This is a big part of what I do with these data models - figure out a 
good default mapping of a relational model onto chunks that can be 
serialized. Based on applying a set of heuristics to the data 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: Is it possible to create a circular reference in Elm?

2017-03-20 Thread Martin Norbäck Olivers


> The reason I was thinking about it was not actually anything to do with 
> garbage collection. I have a data modelling language with a type system, 
> but it has grown in a slightly ad-hoc manner and needs some 
> rationalization. I was wondering how well the type alias records + tagged 
> unions + basic types part of Elm would suit my purposes. As the data models 
> I build are often mapped onto relational database or mutable objects, I do 
> need circular references to be possible.
>

I don't see the rationale for requiring circular references to map onto a 
relational database though, they are referenced by key, not by pointer.
Mutable objects can of course use circular references, and some algorithms 
depend heavily on them, but they are a pain to handle for instance when 
serializing. Which you do a lot in a web app.

-- 
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: Is it possible to create a circular reference in Elm?

2017-03-20 Thread 'Rupert Smith' via Elm Discuss
On Saturday, March 18, 2017 at 5:24:16 PM UTC, Mark Hamburg wrote:
>
> I've been thinking about this as well because functional languages should 
> provide a great basis for exploiting multi core systems.
>

The reason I was thinking about it was not actually anything to do with 
garbage collection. I have a data modelling language with a type system, 
but it has grown in a slightly ad-hoc manner and needs some 
rationalization. I was wondering how well the type alias records + tagged 
unions + basic types part of Elm would suit my purposes. As the data models 
I build are often mapped onto relational database or mutable objects, I do 
need circular references to be possible.

-- 
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: Is it possible to create a circular reference in Elm?

2017-03-18 Thread Mark Hamburg
I've been thinking about this as well because functional languages should 
provide a great basis for exploiting multi core systems. You can run the 
evaluation of a "top level" function like `update` in a bump arena allocator — 
and can even re-run the function safely if the arena turns out to be too small 
— and then copy the results out to RC space. This helps with passing data to 
parallel evaluators. It provides rapid collection for large external resources 
like images. All really nice.

But Elm can produce circular references in the form of mutually recursive 
functions. In fact, a self-recursive function has a circular reference albeit a 
special case one that could probably avoid a reference count addition. An 
ability to recognize function free data structures — useful for safe equality 
checks as well — could help but consider that effects manager states are not 
function free nor are Html node structures. So, now you have to partition the 
persistent world into GC data and RC data. There might still be benefits in 
terms of handing off RC data between processors but the introduction of GC 
eliminates the possibility of rapid collection.

What I haven't dug into us whether the mutual references in functions can be 
managed by having all of the functions belong to a let context object that they 
know about and which gets special handling in the reference count design. If 
that could be made to work, we'd be back into a reference counting friendly 
space.

Mark

> On Mar 17, 2017, at 3:26 PM, 'Rupert Smith' via Elm Discuss 
>  wrote:
> 
>> On Thursday, March 16, 2017 at 5:06:59 PM UTC, Rupert Smith wrote:
>> I am guessing the answer is no.
>> 
>> type alias Reader { borrowing : List Book }
>> type alias Book { reader : Maybe Reader }
> 
> My observation about this is that with statically typed languages, the 
> underlying programming language is usually prevented from doing things by the 
> type system to make it more safe. 
> 
> In this case, the type system will happily accept something, but it is the 
> operational specification of the programming language that restricts what the 
> type system allows.
> -- 
> 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] Re: Is it possible to create a circular reference in Elm?

2017-03-17 Thread 'Rupert Smith' via Elm Discuss
On Thursday, March 16, 2017 at 5:06:59 PM UTC, Rupert Smith wrote:
>
> I am guessing the answer is no.
>
> type alias Reader { borrowing : List Book }
> type alias Book { reader : Maybe Reader }
>

My observation about this is that with statically typed languages, the 
underlying programming language is usually prevented from doing things by 
the type system to make it more safe. 

In this case, the type system will happily accept something, but it is the 
operational specification of the programming language that restricts what 
the type system allows.

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