Git Product home page Git Product logo

nonempty-containers's People

Contributors

alexfmpe avatar andremarianiello avatar eddiemundo avatar emilypi avatar fosskers avatar mitchellwrosen avatar mstksg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nonempty-containers's Issues

NonEmpty Vectors

Hey @mstksg - loving the library! Would you mind a PR for non-empty vectors, or do you have a particular reason why this was not included? I'd be happy to take this on.

Error compiling with GHC 9.0

When I try and build with GHC 9.0, I get an error like this:

[ 1 of 12] Compiling Data.IntMap.NonEmpty.Internal ( src/Data/IntMap/NonEmpty/Internal.hs, dist/build/Data/IntMap/NonEmpty/Internal.o, dist/build/Data/IntMap/NonEmpty/Internal.dyn_o )

src/Data/IntMap/NonEmpty/Internal.hs:184:20: error:
    • Couldn't match type: c (t0 a)
                     with: forall d. Data d => c (t d)
      Expected: (forall d. Data d => c (t d)) -> Maybe (c (NEIntMap a))
        Actual: c (t0 a) -> Maybe (c (NEIntMap a))
    • In the expression: gcast1
      In an equation for ‘dataCast1’: dataCast1 = gcast1
      In the instance declaration for ‘Data (NEIntMap a)’
    • Relevant bindings include
        dataCast1 :: (forall d. Data d => c (t d))
                     -> Maybe (c (NEIntMap a))
          (bound at src/Data/IntMap/NonEmpty/Internal.hs:184:3)
    |
184 |   dataCast1      = gcast1
    |                    ^^^^^^

union a NEMap / NESet with Map / Set?

I know it opens a can of worms in terms of naming, but I missed a union version of NEMap.insertMap which still gets the O(m*log(n/m + 1)), m <= n complexity.

I'm using something like:

unionMap1 :: Ord a => Map a b -> NEMap a b -> NEMap a b
unionMap1 m n = NEMap.withNonEmpty n (<> n) m

unionMap2 :: Ord a => NEMap a b -> Map a b -> NEMap a b
unionMap2 n m = NEMap.withNonEmpty n (n <>) m

I'm happy to open a PR if you like these, but could use some help choosing names.

uncons-style function or pattern for NESet

Given that NESet guarantees the presence of at least one element, it would be nice to have something like this:

uncons :: NESet a -> (a, Set a)

This could be a pattern instead. The idea is that it gives back a pair of the smallest element (by Ord) and whatever's left. This could be very useful for what I'm currently trying to do.

Adding a `IsList NESet` instance

I know already that IsList NESet is not safe because of [ ] :: NESet a.

But considering that there exists already in the base an IsList NonEmpty instance,
it might come as handy especially in a ghci REPL, where I guess people have OverloadedLists enabled to inputs sets,maps,lists,nonempty's more fast.

Unified `from/toNonEmptyList`, à la `GHC.Exts.IsList`

I think it would be handy to have a standard conversion from nonempty list-like containers to nonempty lists:

class (HasNonEmpty s, IsList s) => IsNonEmptyList s where
  fromNonEmptyList :: NonEmpty (Item s) -> NE s
  toNonEmptyList :: NE s -> NonEmpty (Item s)

where Item is the associated type for IsList. Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.