Skip to content

jdkr/HaskellArchitectureProposal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Haskell core library dependency analysis and language architecture proposal

Date: 2022-Jun-27

The possibility that everyone can contribute to the Haskell ecosystem is a big advantage. On the other side, this can potentially cause some friction in the community. I think there could be a lot of potential released if the many bright minds who write Haskell would become a bit more coordinated through some loose guidelines. I'm not aware of any architectural guidelines for writing Haskell libraries, so thought I would share my ideas.
Since Haskell is the basis of my work and the language has evolved a lot since Haskell2010, I would like to see an official language specification. In the last 5 years since I've been using Haskell, I feel like that things don't really make progress in this regard, e.g. the failure of the Haskell2020 specification. Also it's sad to see that all Haskell compilers except GHC died years ago. This is mainly due to the extensive use of GHC language extensions and internal parts of GHC in libraries.

Dependency Analysis

While I feel like some things could be better, I see that if you only use libraries that are used be many people and have less dependencies on their own, things are quite unproblematic. Thankfully Hackage has the feature to see how often a package is downloaded. Also there is the useful reverse dependency site. To figure out how things could be improved I first looked on the dependencies of the core libraries. The base library and core libraries are enclosed in the big circle:

Some things that stand out:

  • There are non core libraries that are used by core libraries.
  • Some core libraries directly use internals of GHC.
  • The deepseq library is most commonly used by other core libraries, so there are probably features included that would be better off including in base.

Architecture proposal

One of Haskell's concepts are pure functions. So why not have something like a pure architecture and decouple core libraries from each other such that each library only depends on the base library?

What would be the attributes of the core libraries?

  • A core library is one that only depends on base and is declared as such from the maintainers
  • Once a library is declared as "core" it's status should not changed again to "non core"
  • Dependencies among different core libraries should be not allowed.
  • GHC language extensions shouldn't be used by core libraries.
  • Core library authors and maintainers should actively request their needed features from the base library maintainers.
  • Datastructures like different array types or text could be a core library.

What would be the attributes of base?

  • Base would be the library where the formal language specifications are implemented.
  • It consists of the generally accepted principles of Haskell.
  • The most useful language extensions could be integrated in base.
  • There shouldn't be fundamental breaking changes from the existing standard. Especially basic datastructures like String and List shouldn't be removed.
  • Primitive data types are included in base.
  • Base should provide low level structures for writing high performance code.
  • Functions in base must not be safe at all cost.
  • Base should be kept small but large enough for core library authors.
  • Base should be independent of GHC.

What would be the benefits of such an architecture?

  • Since each core library has no other dependency than base, the common useful things would be pushed into base. When this architecture would be reached, a new language specification could be derived from base. It would be easier to define from a small base than from the whole set of core libraries.
  • Core libraries would be easier to maintain as they would only depend on base.
  • It would be easier to improve the Haskell ecosystem in the future, as changes in core libraries could be done easier than changes of the language standard.
  • There could be alternative core libraries that do similar things. In the end the best library would prevail.
  • There could be core libraries that focus more on performance and others that focus more on safety.
  • The language standard would naturally evolve as core library authors and maintainers would request things from base they need.
  • With a consensous about the architecture there could be less room for long non constructive debates.
  • Haskell compiler authors would benefit since they would only have to implement the small language standard.
  • It would be better for production environments as one knows what to expect from a core library or a community library.
  • Decisions could be made easier if everyone knows their area of responsibility and the common goal.

Is this a realistic goal?

The dependency graph does not actually look that bad, and we might be going already in that direction.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published