Repository navigation
current assymmetries in exports for Vector wrt Boxed/Unboxed/Generic/Storable #299
Description
Activity
afaict, the best full of examples exposition of backpack is ezyang's well written thesis. (for those who are curious)
https://github.com/ezyang/thesis/releases/tag/rev20170925also i'll try to cleanup these helper scripts so that other folks can easily hack them into having a mostly mechanical way to compare large explicit export lists
- pinned this issue
on Feb 9, 2020 - I’ve not done this comparison for other modules, should I?
- would other folks like me to take a few days to cleanup these compare scripts for easy use?
It looks like you skipped
Primitive, which I think is pretty important one two. I tend to use it instead ofUnboxed, whenever possible. That saidPrimitivelackszipandunzipfunctions, because tuples can't havePriminstance.Storabledoesn't have instances in base for tuples neither, so there is a choice either to provide those instances invectoror not support forzip*/unzip*forStorablestream/unstream/unstreamR/unstreamMare generic by their nature and don't need export fromBoxed/Stroable/Primitive/Unboxed, plus those functions are needed for interoperability with streams, rather than something regular user needs .If the full inventory is needed someone needs to go and check each function one by one, just eyeballing this isn't gonna work
- These lists were generated from some scripts working on the export list. I can run it on that module too. And I should cleanup the workflow I did for the scripts. Prim vectors are essentially just a vector wrapper for the prim helper class in pritmive and deliberately doesn’t have tuples so that it doesn’t dictate the array of structs vs struct of arrays memory layout. There’s definitely some memory layout options missing compared with what vector provides. And I’m hoping backpack is one of those tools to help simplify this. The vector unboxed is struct of arrays. Are you providing an array of structs analogue of unboxed in your own code or what’s the context/ motivation?…On Sun, Feb 16, 2020 at 3:28 PM Alexey Kuleshevich ***@***.***> wrote: It looks like you skipped Primitive, which I think is pretty important one two. I tend to use it instead of Unboxed, whenever possible. That said Primitive lacks zip and unzip functions, because tuples can't have Prim instance. Storable doesn't have instances in base for tuples neither, so there is a choice either to provide those instances in vector or not support for zip* /unzip* for Storable stream/unstream/unstreamR/unstreamM are generic by their nature and don't need export from Boxed/Stroable/Primitive/Unboxed, plus those functions are needed for interoperability with streams, rather than something regular user needs . If the full inventory is needed someone needs to go and check each function one by one, just eyeballing this isn't gonna work — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#299?email_source=notifications&email_token=AAABBQVT7FJTTZQCYVDHFJTRDGOVVA5CNFSM4KSEXJLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4RJGQ#issuecomment-586749082>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAABBQXKQMKDOIHRI66T6GDRDGOVVANCNFSM4KSEXJLA> .
I think it's not possible to achieve uniform API without some tooling. Your script looks like good start for it:
also i'll try to cleanup these helper scripts so that other folks can easily hack them into having a mostly mechanical way to compare large explicit export lists
Just publish it. Then we could just clean it up and extend with exceptions. Such as no
zip/unzipin Storable/Primitive.unstreamonly exported from Generic etcthanks! i'll kick along some stuff during my monday holiday.
Personal motivation for preferring
Primitiveis very simple, it is just as powerful asUnboxed, except for the lack of tuples which I rarely need, but the benefit is compilation times can be a lot less and require less memory (as you've seen with the test suite). That being said, it is irrelevant for this ticket. All I was trying to say is:Primitiveis missing from the list, but is a big part ofvectorlibraryunzip/zipfunctions are not available forStorableandPrimitive
- Ok cool! This is all helpful…On Sun, Feb 16, 2020 at 4:48 PM Alexey Kuleshevich ***@***.***> wrote: Personal motivation for preferring Primitive is very simple, it is just as powerful as Unboxed, except for the lack of tuples which I rarely need, but the benefit is compilation times can be a lot less and require less memory (as you've seen with the test suite). That being said, it is irrelevant for this ticket. All I was trying to say is: - Primitive is missing from the list, but is a big part of vector library - unzip/zip functions are not available for Storable and Primitive — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#299?email_source=notifications&email_token=AAABBQXML5N54YTTMM57GUTRDGYCLA5CNFSM4KSEXJLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4TPAA#issuecomment-586758016>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAABBQUQ5VQFZZ3UFMPSA7LRDGYCLANCNFSM4KSEXJLA> .
i think some of that could be a knock on effect of coercions blowups
@lehins does the timing difference youve found show up in pre 7.10 ghc?replace all the following regexes with \n ,\s* # to split \n\n ,*\s*--.*\n \s*--.*\n \n\s , ,\n+ --\s.*\n # this is subsumed by \s*--.*\n or perhaps \n\s*--.*\n \n\s*\n\s* .--.+\n \s+\n \s*\n # these are equiv to some other ones #to sort this then do cat vector-boxed-exports.txt | sort -o vector-boxed-exports.txt # (if the file has that name of course) #then run the cli too comm comm vector-generic-exports.txt vector-boxed-exports.txt first column is stuff in the left/first file second column is stuff on the right/second file third column is stuff in both!i was doing it semi by hand, but those are all the steps i did, was doing the regex subst via text editor, so hence the half scripted
Just noticed
PrimitivelacksizipWithMandizipWithM_Here is gist with makefile that generate API difference in pure vector: https://gist.github.com/Shimuuar/e95597d9193b558bc466cc167e2fac99
First I think there're functions that are obscure enough that it's fine to export them only from Generic module.(Mostly related to Data.Data)
- dataCast
- gfoldl
- gunfold
- liftReadsPrec
- liftShowsPrec
- mkType
- mkVecConstr
- mkVecType
I'm going to compile list of API differences tomorrow
Here is list. I tried to remove all function that work with tuples from storable/primitive but could missed few.
eq/eqBy/cmp/cmpBy/concatNE were all added in order to define instances. So thre's question whether they should be specialized and reexported.
Vector
- cmp
- cmpBy
- concatNE
- eq
- eqBy
Unboxed
- cmp
- cmpBy
- concatNE
- eq
- eqBy
- iscanl
- iscanl'
- iscanr
- iscanr'
Storable
- cmp
- cmpBy
- concatNE
- eq
- eqBy
- ifoldM
- ifoldM'
- ifoldM'_
- ifoldM_
- imapM
- imapM_
- iscanl
- iscanl'
- iscanr
- iscanr'
- izipWithM
- izipWithM_
Primitive
- cmp
- cmpBy
- concatNE
- eq
- eqBy
- ifoldM
- ifoldM'
- ifoldM'_
- ifoldM_
- imapM
- imapM_
- iscanl
- iscanl'
- iscanr
- iscanr'
- izipWithM
- izipWithM_
Most of asymmetries in pure vectors' API are addressed in #322. Only question that remains is whether we need to add specializations for cmp, cmpBy, eq, eqBy, concatNE. They were added for implementation of Ord1, Eq1, Semigroup instances. So I think it's fine to leave them only in Generic module.
There is definitely no point in adding monomorphic versions of
eq,cmp, andconcatNEsince a more idiomatic way to use them would be with(==),compareandsconcatrespectively. With regards toeqByandcmpBythese could be useful to export from each of the modules, since not only they are a bit more general than justEq1andOrd1, but also these latter instances are only available for boxed vector.I agree with @lehins ,
eqByandcmpByare worth to be exported for each vector flavour. I actually might have used them a couple of times, if they were not so hidden :) BTW these function may benefit from a more elaborate comment.Fixeed in #322. There're still mutable vectors but that's much bigger problem and requires separate issue(s)
- unpinned this issue
on Jan 17, 2021
i've some half scripted stuff i used to generate comparisons of exports and help with me getting the backpack stuff started
this comparison uses v0.12.1.2 (current most recent release)
stuff in Generic but not in boxed: (alphabetical order)
(some stuff spuriously shows up as being different when its Reexported with G.whatever,i've removed those from the list i generated)
missing stuff in storable
and then in unboxed
i might be skipping mentionign 1-2 here,
but if backpack actually materially helps us PROPERLY enforce consistent apis and making it way user to write new flavores of instances with good inference, etc etc
cc @merijn @chessai @andrewthad @lehins @Shimuuar fyi
i'm skipping mentoing 1-2 like
(un)stream(R)and theDataclass helpers on 1-2 of the lists, but this should have good coverage of all the current warts