Git Product home page Git Product logo

Comments (5)

jwaldmann avatar jwaldmann commented on August 29, 2024 2

can you demonstrate (by a concrete example) that the proposed functions help to improve your code?

I think (as a user/teacher) the bar should be quite high for non-essential extensions of the API (where "essential" = "not expressible by functions that are already present")

other uses of uncons: https://hoogle.haskell.org/?hoogle=uncons&scope=set%3Astackage but it seems to me that these don't have views/patterns.

if you want concise code, then this (using patterns) seems quite good:

ghci> import Data.Sequence
ghci> s = Data.Sequence.fromList [1,2,3]
ghci> case s of x :<| xs -> xs

note that you don't need case (somefunction s) of

from containers.

jwaldmann avatar jwaldmann commented on August 29, 2024 1

we do have views that solve exactly this problem?

https://hackage.haskell.org/package/containers-0.7/docs/Data-Sequence.html#g:7

from containers.

meooow25 avatar meooow25 commented on August 29, 2024 1

The naming is tentative...

I have seen these two be commonly called uncons and unsnoc in Haskell libraries.

I think it would be useful to have a function in Data.Sequence that deletes the edge value and at the same time retrieves the rest of the Sequence without the edge value.

There are already two ways to do this:

  • viewl and viewr (as jwaldmann has said)
  • The patterns Empty, :<| and Empty, :|>

But I can see the utility in adding these for Sequence for 1. consistency (with other Haskell structures that define uncons and unsnoc) and 2. convenience of working with the result (for instance, we could say safeLast = fmap snd . unsnoc).

from containers.

sanao1006 avatar sanao1006 commented on August 29, 2024

There are already two ways to do this:

Yes, you are right. I think it is possible to implement both unsnoc and uncons by using viewl and viewr.

I would be inclined to create a PR if only the maintainer would allow me to do so.

from containers.

sanao1006 avatar sanao1006 commented on August 29, 2024

@jwaldmann

I've thought a lot about your opinion. Indeed, the functions I suggested are functions that can be expressed by existing functions, so if I add these functions, it could compromise the compactness of the library.

I decided that if users want to use these functions, they should implement them themselves in their own projects and use them.

So it seems that it is not necessary to add these functions

Thank you for your valuable opinion!
Please close this issue if no problem.

from containers.

Related Issues (20)

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.