From 5b67ca2164b58a24b7bf38757157d9b15a992b20 Mon Sep 17 00:00:00 2001 From: hashirama Date: Tue, 20 Jan 2026 03:24:16 +0000 Subject: [PATCH 1/2] use the target function the processDictionary function is the one we need to use for lookups, because it inserts all resources and gives just the full html at the end, ready to be displayed Signed-off-by: hashirama --- cli-example/Main.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cli-example/Main.hs b/cli-example/Main.hs index 99cc0d0..56695f8 100644 --- a/cli-example/Main.hs +++ b/cli-example/Main.hs @@ -3,17 +3,22 @@ import System.Environment (getArgs) import System.Exit (exitFailure) import Control.Monad (when) -import MDict (lookupInCollection) +import MDict main :: IO () main = do - args <- getArgs - when (length args < 2) $ do - putStrLn "Usage: Main " - exitFailure + args <- getArgs + when (length args < 2) $ do + putStrLn "Usage: Main " + exitFailure - let dictDir = args !! 0 - queryKey = args !! 1 + let dict = args !! 0 + queryKey = args !! 1 - -- Process all files - lookupInCollection dictDir queryKey + res <- processDictionary dict queryKey + html <- case res of + Left err -> error err + Right h -> return h + + + putStrLn (html) From 60f4cc8216ba102d4b186e1ccdb0146fd1fdd0bf Mon Sep 17 00:00:00 2001 From: hashirama Date: Tue, 20 Jan 2026 03:27:06 +0000 Subject: [PATCH 2/2] fix FFI Signed-off-by: hashirama --- MDict.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MDict.hs b/MDict.hs index ec4fc26..406bbba 100644 --- a/MDict.hs +++ b/MDict.hs @@ -75,8 +75,8 @@ isMDDFile path = map toLower (takeExtension path) == ".mdd" -- FFI imports foreign import ccall "mdict_init" c_mdict_init :: CString -> IO (Ptr ()) -foreign import ccall "mdict_destory" c_mdict_destroy :: Ptr () -> IO CInt -foreign import ccall "&mdict_destory" raw_mdict_destroy_finalizer :: FunPtr (Ptr () -> IO CInt) +foreign import ccall "mdict_destroy" c_mdict_destroy :: Ptr () -> IO CInt +foreign import ccall "&mdict_destroy" raw_mdict_destroy_finalizer :: FunPtr (Ptr () -> IO CInt) foreign import ccall "mdict_lookup" c_mdict_lookup :: Ptr () -> CString -> Ptr (Ptr CChar) -> IO () foreign import ccall "mdict_atomic_lookup" c_mdict_atomic_lookup :: CString -> CString -> IO CString foreign import ccall "mdict_locate" c_mdict_locate :: Ptr () -> CString -> Ptr (Ptr CChar) -> CInt -> IO ()