summaryrefslogtreecommitdiff
path: root/ghc/misc/examples/io/io010/Main.hs
blob: 764290c7549639777d3662376ad8313b64c3aa3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import LibDirectory (getCurrentDirectory, setCurrentDirectory, 
                     createDirectory, removeDirectory, getDirectoryContents)

main =
    getCurrentDirectory >>= \ oldpwd ->
    createDirectory "foo" >>
    setCurrentDirectory "foo" >> 
    getDirectoryContents "." >>= \ [n1, n2] ->
    if dot n1 && dot n2 then
        setCurrentDirectory oldpwd >>
        removeDirectory "foo" >>
        putStr "Okay\n"
    else
        fail "Oops"


dot :: String -> Bool
dot "." = True
dot ".." = True
dot _ = False