Skip to content

Conversation

mmhat
Copy link
Collaborator

@mmhat mmhat commented Sep 19, 2022

This PR splits Dhall.Syntax into several smaller modules to mitigate the effect of https://gitlab.haskell.org/ghc/ghc/-/issues/5642 and https://gitlab.haskell.org/ghc/ghc/-/issues/5642 - namely the excessive space usage at built time caused by the Generic instance of Dhall.Syntax.Expr. Most datatypes from Dhall.Syntax were moved to own modules in the Dhall.Syntax namespace and the derivation/declaration of type class instances for the datatypes were grouped in modules below Dhall.Syntax.Instances. Everything from the new modules gets re-exported by Dhall.Syntax and are internal to the dhall package; Nothing should change from a users point of view.
The memory consumed during a run of cabal build dhall drops from ~1200 MB to ~800 MB and the build time decreases slightly.

I also removed the superfluous PreferFromWith data constructor which simplifies the PreferAnnotation type. Note that this is a breaking change.

Fixes #2313

 - Moved functions and optics to Dhall.Syntax.Operations
 - Moved types to Dhall.Syntax.Types
 - Moved instances for the following classes to own modules in
   Dhall.Syntax.Instances:
    - Applicative
    - Bifunctor
    - Data
    - Eq
    - Foldable
    - Functor
    - Lift
    - Monad
    - Monoid
    - NFData
    - Ord
    - Pretty
    - Semigroup
    - Show
    - Traversable
   Only the following instances are in Dhall.Syntax.Types: Generic,
   IsString, Bounded, Enum
 - Monad Expr is using Monad Applicative and not the other way round
 - Expr lives in Dhall.Syntax.Expr
 - Import and friends live in Dhall.Syntax.Import
 - Const lives in Dhall.Syntax.Const
 - Var lives in Dhall.Syntax.Var
Copy link
Collaborator

@Gabriella439 Gabriella439 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I think the breaking change is fine

Feel free to merge once tests pass

@mmhat mmhat merged commit e9efecb into dhall-lang:master Sep 20, 2022
@mmhat mmhat deleted the 2313-split-syntax branch September 20, 2022 21:34
sjakobi added a commit that referenced this pull request Sep 29, 2022
The refactoring in #2449 introduced an infinite loop, because join
is itself defined via (>>=).

Fixes #2454.
sjakobi added a commit that referenced this pull request Sep 29, 2022
The refactoring in #2449 introduced an infinite loop, because join
is itself defined via (>>=).

Fixes #2454.
@mmhat mmhat restored the 2313-split-syntax branch December 8, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hydra sometimes runs out of memory while building dhall
2 participants