Code Monkey home page Code Monkey logo

Comments (3)

ndmitchell avatar ndmitchell commented on May 3, 2024 1

Yeah, I think I'll close this for now, and not add it. But if in 6 months time or so you've needed to use that one a lot, but not any of the other variations with isExtensionOf, it might be worth considering.

from extra.

ndmitchell avatar ndmitchell commented on May 3, 2024

The second one seems redundant - it's easier to do listToMaybe over the first, or whatever is the right policy to reduce many files down to one.

For filesWithExtension, what's the benefit over just doing the listFiles and a filter? My concern is you often want to list files directly, with recursion, and with recursion avoiding . prefixed directories or similar. By the time you have three variants it starts to explode badly in terms of complexity.

from extra.

juhp avatar juhp commented on May 3, 2024

This an implementation of filesWithExtension:

filesWithExtension :: FilePath -> String -> IO [FilePath]
filesWithExtension dir ext =
  filter (ext `isExtensionOf`) <$> listFiles dir

I admit it looks pretty straightforward (specially when one remembers to use isExtensionOf).
Maybe listFilesWithExtension would be a better name.

I see your point, though I find myself using filesWithExtension (and less often fileWithExtension) in various projects: it is a bit less typing. :-)

from extra.

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.