2import Control.ST.ImplicitCall
4data Access = LoggedOut | LoggedIn
5data LoginResult = OK | BadPassword
7interface DataStore (m : Type -> Type) where
8 data Store : Access -> Type
10 connect : ST m Var [add (Store LoggedOut)]
11 disconnect : (store : Var) -> ST m () [remove store (Store LoggedOut)]
13 readSecret : (store : Var) -> ST m String [store ::: Store LoggedIn]
14 login : (store : Var) ->
15 ST m LoginResult [store ::: Store LoggedOut :->
16 (\res => Store (case res of
18 BadPassword => LoggedOut))]
19 logout : (store : Var) ->
20 ST m () [store ::: Store LoggedIn :-> Store LoggedOut]
22getData : (ConsoleIO m, DataStore m) =>
23 (failcount : Var) -> ST m () [failcount ::: State Integer]
25 = do st <- call connect
27 | BadPassword => do putStrLn "Failure"
29 write failcount (fc + 1)
30 putStrLn ("Number of failures: " ++ show (fc + 1))
33 secret <- readSecret st
34 putStrLn ("Secret is: " ++ show secret)
39getData2 : (ConsoleIO m, DataStore m) =>
40 (st, failcount : Var) ->
41 ST m () [st ::: Store {m} LoggedOut, failcount ::: State Integer]
44 | BadPassword => do putStrLn "Failure"
46 write failcount (fc + 1)
47 putStrLn ("Number of failures: " ++ show (fc + 1))
49 secret <- readSecret st
50 putStrLn ("Secret is: " ++ show secret)
55 Store x = State String -- represents secret data
57 connect = do store <- new "Secret Data"
60 disconnect store = delete store
62 readSecret store = read store
64 login store = do putStr "Enter password: "
66 if p == "Mornington Crescent"
69 logout store = pure ()
72main = run (do fc <- new 0
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list