Haskell-OpenAPI-Code-Generator / Haskell-OpenAPI-Client-Code-Generator

Generate Haskell client code from an OpenAPI 3 specification
47 stars 19 forks source link

Improve compile performance #24

Closed joel-bach closed 4 years ago

joel-bach commented 4 years ago

The compile performance on my computer is improved by around 20% (from 7 minutes to 5.6 minutes). With the .hs-boot files, there is no longer a big memory requirement for compilation.

joel-bach commented 4 years ago

Super cool. Can you explain how the hs-boot files work?

The hs-boot files allow to break the import cycles as they contain data and type declarations without a body. GHC then compiles (where necessary, namely where the {-# SOURCE #-} pragma appears in imports) the hs-boot to hi-boot and uses this file to compile the hs files in turn (see https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate_compilation.html#how-to-compile-mutually-recursive-modules).

In our case it allows the splitting of all (root) models into their own module even if they contain cyclic imports.