Alexey Orlov
Alexey Orlov

Reputation: 2804

Haskell: Turtle: Managing Shell type

This a working snippet:

import Turtle
...
groom :: FilePath -> IO ()
groom src = do
  view (ls src)
...

I can see a list of paths on the console. Actually I'd like to have something like [FilePath] for use, e.g.:

treeCount :: FilePath -> Int
treeCount src = length (lstree src)

Naturally, it won't compile, lstree being what it is:

lstree :: FilePath -> Shell FilePath

What is the correct way to treat this Shell thing? It's a newbie question, sorry.

Upvotes: 0

Views: 88

Answers (1)

melpomene
melpomene

Reputation: 85767

I haven't actually tried this, but just looking at the type signatures the following might work:

import qualified Control.Foldl as F

treeCount :: FilePath -> IO Int
treeCount src = fold (lstree src) F.length

Fold with F.list to get [FilePath] instead.

Upvotes: 1

Related Questions