HsHyperEstraier-0.3.2.1: examples/HelloWorld.hs
{- -*- Coding: utf-8 -*- -}
import Network.URI
import System.Directory
import Text.HyperEstraier
main = do withDatabase "casket" (Writer [Create []]) $ \ db ->
do doc <- newDocument
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)
putStrLn ">> Trying to search for \"hêllö\"..."
cond' <- newCondition
setPhrase cond' "hêllö"
result' <- searchDatabase db cond'
putStrLn (">> Found: " ++ show result')
if null result' then
putStrLn ">> Great, hêllö doesn't match to hello."
else
putStrLn (">> 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"