daml/libs-haskell/da-hs-base
Martin Huschenbett f0e5bed36f
DAML-LF: Add interning for type to DAML-LF 1.dev (#7893)
* DAML-LF: Add interning for type to DAML-LF 1.dev

We add two new features to DAML-LF 1.dev:

* a per package list (or table) of `Type` messages, and
* a new case in the `Type` message which is an index into this table.

In combination, these two features can be used to allow DAML-LF
encoders to perform hash-consing of `Type` messages. We also change the
Haskell implementation of our DAML-LF encoder to do exactly that when
targetting DAML-LF 1.dev.

Doing this has a few benefits:

1. The DALFs produced by `damlc` get smaller: I've seen a case where
   the size dropped from 69MB to 45MB.
2. DAML-LF decoders need to decode less data.
3. Decoded packages use less memory because identical structures are
   now shared. This is particularly helpful in situations where we need
   to keep the interface (or signature) of a package in memory for a
   long time.

This PR mostly takes care of the Haskell implementation. However, we
need to make the Scala implementation of the decoder aware of the new
features as well since we have tests that load DAML-LF 1.dev into the
engine. A decoder and _targeted_ tests on the Scala side will follow
in a separate PR.

CHANGELOG_BEGIN
CHANGELOG_END

* Make jq tests aware of type interning

CHANGELOG_BEGIN
CHANGELOG_END

* Improve jq test

CHANGELOG_BEGIN
CHANGELOG_END

* Apply Remy's suggestions

Co-authored-by: Remy <remy.haemmerle@daml.com>

* Improve the imperative bits

CHANGELOG_BEGIN
CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
2020-11-18 11:14:30 +00:00
..
src DAML-LF: Add interning for type to DAML-LF 1.dev (#7893) 2020-11-18 11:14:30 +00:00
tests replace DAML Authors with DA in copyright headers (#5228) 2020-03-27 01:26:10 +01:00
BUILD.bazel replace DAML Authors with DA in copyright headers (#5228) 2020-03-27 01:26:10 +01:00
da-hs-base.cabal DEL-8132 extract DAML LF haskell libraries (scripted) (#7246) 2020-09-01 12:09:26 +10:00
LICENSE open-sourcing daml 2019-04-04 09:33:38 +01:00
README.md open-sourcing daml 2019-04-04 09:33:38 +01:00

Base library for DA Haskell code

The libraries provided by Hackage adapted to the needs of DA.

The intention of this version of this library published as part of Simon Meier's HaskellerZ talk on 2016-01-27 is that it serves as an inspirational source for how to adapt Hackage to a company's needs. DA currently does not plan to provide an officially supported version of this library. However, we very much encourage people to take and reshape this code into a library that allows to share this kind of Hackage-adaption-code.

Slides Video