Closed safareli closed 6 years ago
It'll probably happen, but it requires some reorganisation of the libraries - the instances for records will have to live with the class definitions to prevent them from being orphans (since record is a Prim
type) - so for that to happen, -typelevel-prelude
needs to be merged with or moved above -prelude
in the dependency hierarchy.
I think we should move the minimal amount of stuff needed to support this (i.e. RowList
and classes) into Prelude as part of the 0.12.0 updates.
FWIW, in the meantime I've created this, which I find helpful: https://github.com/matthewleon/purescript-record-show
Do you think it might be worth considering doing it before then? Just because all the stuff is already there and ready to go, it seems a shame to wait, and even after 0.12 is out I think it would be nice if people could take advantage of this without having to upgrade. Presumably this would only be a minor-level change for Prelude, and I don't think that would cause a huge amount of hassle since most people seem to be using caret (^) bounds for most dependencies..?
We definitely could, especially since there is no plan for continued work on 0.12 right now anyway.
Great! Looking at @matthewleon's record-show library, I guess that means the following would need to be moved above or into Prelude in the dependency hierarchy:
import Data.Record (get, delete)
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Type.Prelude (class RowToList, class RowLacks)
import Type.Row (kind RowList, Nil, Cons, RLProxy(..))
Does that seem doable? Or is there maybe a way of achieving this without using all of these?
Come to think of it I suppose we could avoid the record
dependency by cheating and using the FFI...? Also we could probably switch out delete
for a version of unsafeCoerce
which is specialised to have the same type, in order to avoid doing unnecessary work.
Come to think of it I suppose we could avoid the record dependency by cheating and using the FFI...?
Is there FFI use elsewhere in the Prelude?
Yes; most of the Show instances need it, for example.
On second thoughts, since we are moving some of these classes in 0.12, it's probably best to wait until 0.12. See https://github.com/purescript/purescript/issues/2903
These now exist in the 0.12 version of the prelude.