File: myapp2.hs

package info (click to toggle)
tokyocabinet-haskell 0.0.5-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 308 kB
  • sloc: haskell: 2,276; makefile: 3
file content (19 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import MyApp2.TokyoCabinet

import Control.Monad.Trans
import Control.Monad.Error

main :: IO ()
main = do h <- new :: IO HDB
          let ext = defaultExtension h
          v <- flip runTCM h $ do
                 open ("foo" ++ ext) [OWRITER, OCREAT]
                 put "100" "foo"
--                 throwError EMISC
                 v <- get "100"
                 close
                 return v
               `catchError` const (close >> fail "oops")
          case v of
            Left  e  -> putStrLn (show e)
            Right v' -> putStrLn (show (v' :: Maybe String))