Skip to content

current assymmetries in exports for Vector wrt Boxed/Unboxed/Generic/Storable #299

Description

@cartazio

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)

clone
cmp
cmpBy
concatNE
eq
eqBy


gfoldl
gunfold
liftReadsPrec
liftShowsPrec

new

readPrec
showsPrec

stream
streamR

unstream
unstreamR

(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

ifoldM
ifoldM'
ifoldM'_
ifoldM_
imapM
imapM_
iscanl
iscanl'
iscanr
iscanr'
izipWithM
izipWithM_
new

sequence
sequence_
unsafeAccumulate  
unsafeUpdate  
       
unstream
unstreamR
unzip
unzip3
unzip4
unzip5
unzip6
update

zip
zip3
zip4
zip5
zip6

and then in unboxed

clone
cmp
cmpBy
concatNE
eq
eqBy
gfoldl
gunfold
iscanl
iscanl'
iscanr
iscanr'
sequence
sequence_

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 the Data class helpers on 1-2 of the lists, but this should have good coverage of all the current warts

Activity

  1. cartazio commented on Feb 9, 2020

    @cartazio
    ContributorAuthor

    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/rev20170925

  2. cartazio commented on Feb 9, 2020

    @cartazio
    ContributorAuthor

    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

  3. pinned this issue on Feb 9, 2020
  4. cartazio commented on Feb 10, 2020

    @cartazio
    ContributorAuthor
    1. I’ve not done this comparison for other modules, should I?
    2. would other folks like me to take a few days to cleanup these compare scripts for easy use?
  5. lehins commented on Feb 16, 2020

    @lehins
    Contributor

    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

  6. cartazio commented on Feb 16, 2020

    @cartazio
    ContributorAuthor
  7. Shimuuar commented on Feb 16, 2020

    @Shimuuar
    Contributor

    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/unzip in Storable/Primitive. unstream only exported from Generic etc

  8. cartazio commented on Feb 16, 2020

    @cartazio
    ContributorAuthor

    thanks! i'll kick along some stuff during my monday holiday.

  9. lehins commented on Feb 16, 2020

    @lehins
    Contributor

    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
  10. cartazio commented on Feb 16, 2020

    @cartazio
    ContributorAuthor
  11. cartazio commented on Feb 17, 2020

    @cartazio
    ContributorAuthor

    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?

  12. cartazio commented on Feb 17, 2020

    @cartazio
    ContributorAuthor

    @Shimuuar

    
    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!
    
  13. cartazio commented on Feb 17, 2020

    @cartazio
    ContributorAuthor

    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

  14. lehins commented on Feb 19, 2020

    @lehins
    Contributor

    Just noticed Primitive lacks izipWithM and izipWithM_

  15. added this to the 0.13 milestone on Jun 11, 2020
  16. Shimuuar commented on Jun 19, 2020

    @Shimuuar
    Contributor

    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

  17. Shimuuar commented on Jun 20, 2020

    @Shimuuar
    Contributor

    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_
  18. Shimuuar commented on Jun 24, 2020

    @Shimuuar
    Contributor

    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.

    @lehins @Bodigrim You opinion?

  19. lehins commented on Jun 24, 2020

    @lehins
    Contributor

    There is definitely no point in adding monomorphic versions of eq, cmp, and concatNE since a more idiomatic way to use them would be with (==), compare and sconcat respectively. With regards to eqBy and cmpBy these could be useful to export from each of the modules, since not only they are a bit more general than just Eq1 and Ord1, but also these latter instances are only available for boxed vector.

  20. Bodigrim commented on Jun 24, 2020

    @Bodigrim
    Contributor

    I agree with @lehins , eqBy and cmpBy are 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.

  21. Shimuuar commented on Jul 12, 2020

    @Shimuuar
    Contributor

    Fixeed in #322. There're still mutable vectors but that's much bigger problem and requires separate issue(s)

  22. unpinned this issue on Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions