Last active
April 30, 2017 00:19
-
-
Save fragamus/6a54eb38952aaeefdf32a5e0636cec11 to your computer and use it in GitHub Desktop.
the counter handled by stateT isn't changing with modify (+1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package turtle | |
{-# LANGUAGE OverloadedStrings #-} | |
import Prelude hiding (FilePath) | |
import Turtle | |
import Control.Monad.State | |
import Data.Text | |
import Filesystem.Path.CurrentOS | |
import Data.Either | |
import Data.Either.Utils | |
main = view $ ((flip runStateT) 0) $ filePathProducer baseDirectory | |
baseDirectory = Filesystem.Path.CurrentOS.fromText "." | |
filePathProducer path = do | |
child <- lift $ lstree path | |
modify (+1) | |
i <- get | |
if (i `mod` 3 == 0) | |
then (lift . echo) "**********************************" | |
else (lift . echo . Data.Text.pack . show) i | |
(lift . echo . fromRight . toText) child |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample output:
[1 of 1] Compiling Main ( ../ii.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
1
./a1
((),1)
1
./a2
((),1)
1
./a3
((),1)
1
./a4
((),1)
1
./a5
((),1)
1
./a6
((),1)
1
./b/b1
((),1)
1
./b/b2
((),1)
1
./b/b3
((),1)
1
./b/b4
((),1)
1
./b/b5
((),1)
1
./b/b6
((),1)
1
./b/c/c1
((),1)
1
./b/c/c2
((),1)
1
./b/c/c3
((),1)