Discussion:
[elm-discuss] Extensible records and compiler running out of memory
Steve Schafer
2017-07-06 17:42:40 UTC
Permalink
I was experiencing some issues with elm-make running very slowly and
consuming vast amounts of memory, which eventually led to out-of-memory
errors.

I tracked it down to some hierarchically-defined extensible records, along
the lines of:

type alias Identified a =
{ a | id : Int }

type alias Named a =
{ a | name : String }

type alias Item a = Identified(Named a)

type alias Sited a =
{ a | db : String }

type alias WithSchema a = (Sited
{ a | schemaId : Int})

type alias Object a = WithSchema(Item a)

By themselves, these type definitions didn't cause a problem, but declaring
additional record types that were derived from these types, and that also
contained fields that were similarly defined, would rapidly increase memory
usage, pretty much in direct proportion to the "interconnectedness" of the
types.

I wasn't able to find any prior discussions of this phenomenon. I can
probably create a reproducible test case if this isn't something that's
already known.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...