I thought of a potential advantage of keeping the behavior as it currently
is: it gives library authors a way of making record types opaque.

Consider a union type.

type Foo = FooA Float | FooB Int | FooC
>

If an author wants the type constructors as part of the public API, their
module header looks like this:

module FooModule exposing (Foo(..))
>

But if they wants to hide the type constructors, they can change it to this:

module FooModule exposing (Foo)
>

A record type always exposes its definition & constructors:

module FooModule exposing (PublicFoo)
> type alias PublicFoo = { a : Float }
>

But using the behavior that Peter asks about, an author can alias the
record and hide its "record-ness" from library users:

module FooModule exposing (PublicFoo)
>
type alias PublicFoo = PrivateFoo
>
type alias PrivateFoo = { a : Float }
>



On Wed, Jun 22, 2016 at 11:17 PM, Peter Damoc <[email protected]> wrote:

> Alex,  your use-case is way more interesting and useful than mine.
>
> What I was trying to do was more like a simple rename.
> I put the MainModel in a different file because it needed to be imported
> in different places and I ended up with a circular dependency but I wanted
> to keep referring to it as Model in the original location.
>
>
>
> On Wed, Jun 22, 2016 at 11:57 PM, Alex Lew <[email protected]> wrote:
>
>> This would be useful to have, especially if it worked on type aliases
>> with type arguments:
>>
>> type alias Container a = { contents : a }
>> type alias IntContainer = Container Int
>>
>> myContainer = IntContainer 3
>>
>> -- Or even this, which would require some decisions about how what order
>> the
>> -- record fields of `Managed Book` would be in.
>> type alias Managed a = { a | managerId : Int }
>> type alias Book = { title : String, author : String }
>> type alias ManagedBook = Managed Book
>>
>> harryPotter = ManagedBook 50321 "Harry Potter" "JK Rowling"
>>
>>
>> On Wednesday, June 22, 2016 at 4:05:04 AM UTC-4, Peter Damoc wrote:
>>>
>>> This does not work:
>>>
>>> type alias MainModel = { int : Int}
>>>
>>> type alias Model = MainModel
>>>
>>> init = Model 1
>>>
>>> and I'm wondering if this is a bug or the expected behavior.
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> There is NO FATE, we are the creators.
>>> blog: http://damoc.ro/
>>>
>> --
>> 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 [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to