{- -*- Coding: utf-8 -*- -}
import qualified Data.ByteString as BS
import Data.Encoding
import Data.Encoding.UTF8
import Network.URI
import System.Directory
import Text.HyperEstraier
main = do withDatabase "casket" (Writer [Create []]) $ \ db ->
do doc <- newDocument Nothing
let Just uri = parseURI "http://example.net/hello"
setURI doc (Just uri)
addText doc "Hello, world!"
putStrLn ">> Registering the following document:"
dumpDraft doc >>= putStr
putDocument db doc []
docID <- getId doc
putStrLn (">> Done. The document got ID " ++ show docID ++ ".")
putStrLn ">> Trying to search for \"World OR dlroW\"..."
cond <- newCondition
setPhrase cond "World OR dlroW"
result <- searchDatabase db cond
putStrLn (">> Found: " ++ show result)
BS.putStrLn (encode UTF8 ">> Trying to search for \"hêllö\"...")
cond' <- newCondition
setPhrase cond "hêllö"
result' <- searchDatabase db cond
putStrLn (">> Found: " ++ show result')
if null result' then
BS.putStrLn (encode UTF8 ">> Okay, hêllö doesn't match to hello.")
else
BS.putStrLn (encode UTF8
(">> hêllö matches to hello... This seems to be indeed a desired behavior, " ++
"but this may cause problems on languages where diacritical marks are " ++
"significant to distinguish completely different words..."))
removeDirectoryRecursive "casket"