{- -*- Coding: utf-8 -*- -}
{-# LANGUAGE
OverloadedStrings
, UnicodeSyntax
#-}
module Main where
import Control.Monad.Unicode
import qualified Data.Text.IO as T
import Network.URI
import System.Directory
import Text.HyperEstraier
import Prelude.Unicode
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 ≫= T.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"