Skip to content

Commit

Permalink
Add an example of using the handle, no intermediate definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Jun 19, 2024
1 parent a5c9ff7 commit 7b592c2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bluefin-internal/src/Bluefin/Internal/Examples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ action fs = do
writeFile fs "/tmp/bluefin" "Hello!\n"
readFile fs "/tmp/doesn't exist"

action' :: e :> es => Handle FileSystem e -> Eff es String
action' fs = do
file <- readFileImpl fs "/dev/null"
when (length file == 0) $ do
writeFileImpl fs "/tmp/bluefin" "Hello!\n"
readFileImpl fs "/tmp/doesn't exist"

exampleRunFileSystemPure :: Either String String
exampleRunFileSystemPure = runPureEff $ try $ \ex ->
runFileSystemPure ex [("/dev/null", "")] action
Expand Down

0 comments on commit 7b592c2

Please sign in to comment.