Abstract Nonsense

Abstract Nonsense

Ramblings by Benjamin Kovach

Theme adapted from minimal by orderedlist.

What's a module system good for anyway?

Published by Ben Kovach on August 11, 2014

Tags: modules, haskell, backpack

Notes on What’s a module system good for anyway?

1. A simple problem: Too many text encodings

  • String
  • ByteString (Strict/Lazy)
  • Text (Strict/Lazy)

See this reddit comment for an explanation of how to fix this. Basic idea: import String and decide upon a concrete representation later on.

2. Destructive package installs

Example:

$ cabal install hakyll
cabal: The following packages are likely to be broken by the reinstalls:
pandoc-1.9.4.5
Graphalyze-0.14.0.0
Use --force-reinstalls if you want to install anyway.

Main idea: pandoc, Graphalyze might have been compiled against a version of some dependency of hakyll that is incompatible with hakyll; need to reinstall everything in order to get this to work. Cabal only allows a single version of a given package to be installed at any point.

3. Version Bounds

Example:

$ cabal install hledger-0.18
Resolving dependencies...
cabal: Could not resolve dependencies:
# pile of output

Version bounds are important, but sometimes this happens because the constraints on dependencies is undecideable (usually due to upper bounds, which are arbitrary a lot of the time). Cabal even has the flag --allow-newer to avoid this!

Idea for a fix: Instead of having versions and dependencies, generate a “module signature” which can be interpreted by the compiler to install the proper dependencies.

comments powered by Disqus