unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 272 forks source link

How can we bundle Unison/codebase definitions with a ucm release? #3306

Open aryairani opened 2 years ago

aryairani commented 2 years ago

This is relevant to both IOSource definitions and base lib.

ChrisPenner commented 2 years ago

Let's make sure we're clear about the issues we want to solve:

Additionally:

One option we discussed:

ChrisPenner commented 2 years ago

I looked into using lift in Template Haskell to lift the compilation of the IOSource typechecked unison file to compile-time, but in order to derive Lift for a typechecked unison file I need to derive it for all dependencies of that type; which includes ShortByteString and that depends on GHC.Prim.ByteArray#, which only got a Lift instance 4 months ago so it won't be available in our base.

Here's the broken attempt at lifting: https://github.com/unisonweb/unison/tree/cp/lifted-unison-file https://gitlab.haskell.org/ghc/ghc/-/commit/83f5841b32ef11c54ff1e24dd5b92bc3c77f6250

So that particular approach is probably a dead-end for now at least, it also required littering the codebase with a ton of lift derivations, but that's maybe not a big deal. I may look into just bundling a codebase next.

ChrisPenner commented 2 years ago

I looked a bit into a codebase bundling approach, I think we could use this to bundle a "kick-start" codebase with definitions from base, but I'm not sure how it relates to the IOSource problem, which as I understand it right now is this:

We also have this problem:

ChrisPenner commented 2 years ago

I tried another approach where I just lift the derived references for the specific things we need.

This was still a pain because we can't lift Hash or ByteString, but I was able to middle-man through Text to get through the lift.

It works, but it's extremely unergonomic for development, easy to make a mistake, requires a bit of unsafe code, and we'd still need to parse the IOSource code at runtime anyways to get a code lookup for the Runtime to use, so this isn't worth it I don't think. This broken version is here