Skip to content

Instantly share code, notes, and snippets.

@kgadek
Created January 12, 2017 17:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kgadek/becd454445a64fd9607bd7967a5b4861 to your computer and use it in GitHub Desktop.
runWithMock :: MockDirectoryTree -> FSops r -> [String]
runWithMock mockTree = cata eval
where
eval :: TF.FreeF FSopsF r [String] -> [String]
eval (TF.Free x@ListDir{}) = msg : cont
where
msg = printf "LISTDIR: %s\n RESULT: %s\n" (x ^. dirName) (show dirListing)
dirListing = DirectoryListing immediateDirs immediateFiles
immediateDirs = mockTree ^.. unFix2 . mDirs . each . rootDirName
immediateFiles = mockTree ^. unFix2 . mFiles
cont = (x ^. continueWithDirectoryListing) dirListing
eval (TF.Pure _) = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment