A very first step towards fragment-based code distribution

Leaving this just to elaborate a little bit since my post was contentless. IMO, imports are stupid and outdated. The whole way code is organized today is stupid. Files and filesystems are not necessary entirely. And there is a link to "author" and "code" that just shouldn't exist. Haskell allow us to do much better. My view is a kind of global encyclopedia of functions. What I'd suggest is that import dies completely and is replaced by a symbolic linking system that lookups on that encyclopedia. That is, mind this program:

SrPeixinho/PrintOne/main.hs
SrPeixinho.PrintOne.main = IO.print (List.head [1,2,3,4])

By having this file on my system I'm actually defining a symbol on the Global Haskell Encyclopedia. If you try to compile this program with GHC today, it will complain IO.print and List.sort are undefined. Instead of failing, it should lookup into that global repository, find the proper entries:

List.head (x : xs) = x
IO.print = ...

It would then download List/head.hs and IO/print.hs to your computer and compile it just fine. Of course, this requires that each symbol ever defined has an unique name, but that is cool. "List.head" has a short name because it is so common. If you are programming a different kind of list, you can just append your name to the namespace. YourName.List.head. Or, even better: you can just be clear about what is the difference and use, instead, "AppendList.head", so the community can help improving on it.

This approach would:

  1. Set us free from ever having looking where something you need is, or to ever type import again.

  2. Set us free from spending hours trying organize our codebase in awkward modules that almost always don't express correctly the dependencies of your code.

  3. Amenize considerably the cabal hell problem since, now, an update in a function only affects programs using that function. Think about it: today, if we have a module with 500 functions, one of which is buggy and barely used... fixing the definition of function will cause every library depending on that module to break, even if only 0.1% of them used that function. That is just stupid.

  4. Pave way to a definite solution of the cabal hell problem, which is prohibiting that someone makes a change on a global function that breaks it quickcheck laws. If that is necessary, that person has to instead use a different name and trigger an warning that the old function is deprecated. The only drawback is that we will lose a namespace, but the guarantee that code will never break again is a really, really good tradeof.

/r/haskell Thread Parent Link - haskellexists.blogspot.de