purenix
purenix copied to clipboard
core library support
This issue is to track which core libraries have been ported to PureNix.
Done
These are libraries that have already been ported.
- [X] arrays: https://github.com/purenix-org/purescript-arrays
- [X] bifunctors: https://github.com/purenix-org/purescript-bifunctors
- [X] const: https://github.com/purenix-org/purescript-const
- [X] contravariant: https://github.com/purenix-org/purescript-contravariant
- [X] control: https://github.com/purenix-org/purescript-control
- [X] distributive: https://github.com/purenix-org/purescript-distributive
- [X] either: https://github.com/purenix-org/purescript-either
- [X] exists: https://github.com/purenix-org/purescript-exists
- [X] foldable-traversable: https://github.com/purenix-org/purescript-foldable-traversable
- [X] functors: https://github.com/purenix-org/purescript-functors
- [X] identity: https://github.com/purenix-org/purescript-identity
- [X] invariant: https://github.com/purenix-org/purescript-invariant
- [X] maybe: https://github.com/purenix-org/purescript-maybe
- [X] newtype: https://github.com/purenix-org/purescript-newtype
- [X] nonempty: https://github.com/purenix-org/purescript-nonempty
- [X] orders: https://github.com/purenix-org/purescript-orders
- [X] partial: https://github.com/purenix-org/purescript-partial
- [X] prelude: https://github.com/purenix-org/purescript-prelude
- [X] profunctor: https://github.com/purenix-org/purescript-profunctor
- [X] safe-coerce: https://github.com/purenix-org/purescript-safe-coerce
- [X] st: https://github.com/purenix-org/purescript-st
- [X] tuples: https://github.com/purenix-org/purescript-tuples
- [X] type-equality: https://github.com/purenix-org/purescript-type-equality
- [X] unfoldable: https://github.com/purenix-org/purescript-unfoldable
- [X] unsafe-coerce: https://github.com/purenix-org/purescript-unsafe-coerce
Todo
These are libraries that still need to be ported.
- [ ] catenable-lists
- [ ] datetime (This might be difficult? I don't think Nix has any built-in support for working with dates or times.)
- [ ] enums
- [ ] filterable
- [ ] foreign (Started by @thought2 in https://github.com/purenix-org/purescript-foreign. Some functions from this library haven't been ported yet, and it is waiting on the
lists
andtransformers
packages being ported. See https://github.com/purenix-org/purenix/issues/40#issuecomment-1019074353 for a little more info.) - [ ] foreign-object
- [ ] free
- [ ] functions
- [ ] graphs
- [ ] integers
- [ ] lazy (This isn't technically necessary, because PureNix is lazy. But it may be nice to have for library compatibility. Also, we probably want something like Haskell's deepseq instead, since Nix does have a
builtins.seq
function.) - [ ] lcg
- [ ] lists
- [ ] math
- [ ] numbers
- [ ] ordered-collections
- [ ] psci-support (I'm not sure what PureNix needs to do to get PSCi working. This library may or may not be needed.)
- [ ] record
- [ ] semirings
- [ ] strings (This would be hard to port as-is, since Nix doesn't have any built-in support for UTF8 or Unicode. However, @-sternenseemann has written a proof-of-concept UTF8 library for Nix that we could likely draw inspiration from.)
- [ ] transformers
- [ ] typelevel-prelude
- [ ] validation
Won't Do / Can't Do
These are libraries that either can't be ported to PureNix, or don't make sense to port to PureNix.
-
Nix does have an
assert
statement, but I'm not sure it would be able to be used with a similar API topurescript-assert
. Creating apurescript-nix-assert
library would likely be better. -
Nix doesn't have any way of writing arbitrary text to the console. There is the
builtins.trace
Nix function, but that could be wrapped up in it's own library. -
I'm not sure what this is or how it would be related to PureNix.
-
Nix doesn't have any way of doing arbitrary effects. In theory, we could have an
Effect
type for compatibility, but in practice we wouldn't be able to do anything interesting with it.edit: There was a little discussion in https://github.com/purenix-org/temp-package-set/pull/1 as to whether or not
purescript-effect
would make sense for PureNix. There are a couple good points in favor of havingpurescript-effect
. -
Nix doesn't really have exceptions the same way JavaScript does. Nix does have the
builtins.abort
,assert
, andbuiltins.tryEval
functions, which may be able to be wrapped up in a nice library. -
See the problem with
random
. -
I don't think Nix has any way of getting the current time (or at least to any precision that would be necessary for benchmarking).
-
Nix doesn't have any built-in way of running computations in parallel. It is possible we could support this same API in PureNix for compatibility, but it is likely we would only be able to run the computations sequentially.
-
See the problem with
random
. -
As far as I know, Nix doesn't have any sort of random number generator. There is no way to generate random numbers.
edit: Thinking about this a little more, we could have
purescript-random
be a pseudorandom number generator (PRNG). All the random functions could just take a seed that has to be passed in. The seed would be the initial seed for the PRNG. This could be useful for people that are willing to pass in a random seed when callingnix-build
. This seems like a reasonable way to use libraries likepurescript-random
,purescript-gen
, andpurescript-quickcheck
. -
Nix doesn't have any way of mutating values, so refs are not possible.
-
Nix is lazy, so this sort of trampolining isn't necessary.
A couple comments:
-
If you'd like to help with this, please leave a message and we can get you setup with a repo for doing the porting.
-
In my experience, the most time-consuming part of this is writing the FFI. For instance,
purescript-arrays
has a lot of FFI, and that took a long time to port. But packages likepurescript-newtype
have no FFI, and that basically takes no time to port. -
It is quite common for libraries to have dependencies on things like
purescript-effect
(forMonadEffect
), orpurescript-tailrec
(forMonadRec
). These type of dependencies and instances can mostly be ignored and deleted from the ported-code, since they aren't used in PureNix. -
Once you're ported a library, make sure to add it to the temporary package set. (Or possibly whatever we decide to do with #36.)
-
I wrote a script for automating some of the manual work when porting a PureScript package (basically cloning the repo, creating a new repo in
purenix-org
, updating the package set, etc): https://github.com/cdepillabout/port-purescript-package. It is unlikely someone else would be able to use this as-is, but it might help get an idea of what needs to be done.
I'm interested in giving one of these a shot, whichever you think is in the intersection of most useful and straight-forward. Any suggestions ?
@martyall We recently released a newer version of purenix
that is based on PureScript-0.15 (instead of 0.14): https://github.com/purenix-org/purenix/pull/51 and https://github.com/purenix-org/purenix/pull/53.
However, we never went back and updated all the actual PureNix PureScript libraries to be based on the versions that are used for the actual PureScript-0.15 package set. All of our current PureNix libraries are based on PureScript libraries that are used with PureScript-0.14. I'm actually pretty surprised that the Quick Start instructions still work even when you use a 0.15 version of PureNix with the current set of libraries based on PureScript-0.14.
So the most helpful thing would probably be to go through all the PureScript libraries that have already been ported to PureNix, and update their versions to the same versions used in the actual PureScript-0.15 package set. Although that would likely be quite annoying to do unless you automated or semi-automated the process!
Other than that, the most helpful thing might be to try to work on some sort of nix-builtins
library as described in https://github.com/purenix-org/purenix/issues/40.
Or, if you're coming from Haskell, one of the most interesting libraries to try to port to PureNix might be purescript-transformers
, since that contains all the monad transformers and mtl type-classes. Having them be available in Nix would be neat.