On Thursday, March 9, 2017 at 8:52:12 AM UTC, Matthieu Pizenberg wrote:
>
> However, as the constructor for Animation is exposed by its module, I am
>> not prevented from deconstructing it or pattern matching against it.
>>
>
> Hmm, I tried to do this but got errors as I thought:
>
> Cannot find pattern `Animation`
> 6| f (Animation { steps, running }) =
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Could you explain how you can abuse this by destructuring or similar?
>
Sorry, my bad for making assumptions. I thought since the compiler refers
to instances of State as having type Animation.Model.Animation msg, that
you could deconstruct it. As per the comment against the State type alias:
_Note_ - The compiler will refer to your `Animation.State` as
`Animation.Model.Animation msg`
Nor can you import Animation.Model:
Warning: I cannot find module 'Animation.Model'.
So I think a type becomes opaque if its constructors are not exposed, or if
its module is not exposed.
It might be better in that case, if the compiler just referred to the
opaque type as Animation.State?
===========
One way you can create a partially exposed type is like this:
module Test exposing (Test(One))
type Test
= One
| Two
The Two constructor is not exposed, but the One constructor is.
--
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.