HsJudy 0.1 → 0.1.1
raw patch · 8 files changed
+10/−227 lines, 8 files
Files
- HsJudy.cabal +5/−11
- Judy/Hash.hs +1/−1
- Judy/HashIO.hs +1/−3
- Judy/MiniGC.hs +1/−1
- Judy/Private.hs +0/−175
- Judy/Private.hsc +1/−1
- Judy/Private_hsc.c +0/−31
- Judy/Refeable.hs +1/−4
HsJudy.cabal view
@@ -1,5 +1,5 @@ name: HsJudy-version: 0.1+version: 0.1.1 Category: Data Synopsis: Judy bindings, and some nice APIs Description: Judy[1] bindings (a C library that implements fast sparse dynamic@@ -31,14 +31,8 @@ exposed-modules: Judy.BitSet Judy.Freeze Judy.Hash Judy.IntMap Judy.StrMap Judy.CollectionsM Judy.HashIO Judy.Refeable Judy.Stringable other-modules: Judy.Private Judy.MiniGC-- include-dirs: . ../judy/Judy-1.0.3/src--- FIXME: make Cabal work nicely with _hsc files; now I think it works, but doesn't clean _hsc files- c-sources: Judy/Private_hsc.c-+ extra-libraries: Judy - extensions: ForeignFunctionInterface, TypeSynonymInstances, MagicHash,- IncoherentInstances, UndecidableInstances- ghc-options: -fglasgow-exts -Wall -O2 -static ../judy/Judy-1.0.3/src/Judy1/*.o- ../judy/Judy-1.0.3/src/JudyL/*.o ../judy/Judy-1.0.3/src/JudySL/*.o- ../judy/Judy-1.0.3/src/JudyHS/*.o ../judy/Judy-1.0.3/src/JudyCommon/*.o+ extensions: ForeignFunctionInterface, TypeSynonymInstances, MagicHash, MultiParamTypeClasses,+ IncoherentInstances, UndecidableInstances, DeriveDataTypeable, FlexibleInstances+ ghc-options: -Wall -O2
Judy/Hash.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS -fallow-undecidable-instances -fallow-incoherent-instances #-}+{-# LANGUAGE MultiParamTypeClasses, UndecidableInstances, IncoherentInstances #-} {-# INCLUDE "Judy.h" #-}
Judy/HashIO.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE MagicHash #-}-{-# OPTIONS -fallow-undecidable-instances -fallow-incoherent-instances -fallow-overlapping-instances #-}+{-# LANGUAGE MagicHash, FlexibleInstances, OverlappingInstances, IncoherentInstances #-} module Judy.HashIO ( HashIO (..),@@ -19,7 +18,6 @@ class UniqueHashIO a => ReversibleHashIO a where -- Two step conversion, first from Value -> Int then Int -> a unHashIO :: Value -> IO a- instance Enum a => UniqueHashIO a where
Judy/MiniGC.hs view
@@ -1,4 +1,4 @@-+{-# LANGUAGE DeriveDataTypeable #-} {-# INCLUDE "Judy.h" #-} module Judy.MiniGC (
− Judy/Private.hs
@@ -1,175 +0,0 @@-{-# INCLUDE "Judy/Private_hsc.h" #-}-{-# LINE 1 "Judy/Private.hsc" #-}--- | Low-level FFI-{-# LINE 2 "Judy/Private.hsc" #-}-module Judy.Private where--import Foreign---{-# LINE 7 "Judy/Private.hsc" #-}-import Data.Word--{-# LINE 11 "Judy/Private.hsc" #-}--import Foreign.C.Types-import Foreign.C.String--{-# INCLUDE "Judy.h" #-}---{-# LINE 18 "Judy/Private.hsc" #-}--{-# LINE 19 "Judy/Private.hsc" #-}---{-# LINE 21 "Judy/Private.hsc" #-}-type Value = WordPtr--{-# LINE 34 "Judy/Private.hsc" #-}--newtype JError = JError (Ptr ())---foreign import ccall unsafe "judy_error" judyError :: JError--- #def JError_t *judy_error(void) { static JError_t err; return &err; }-judyError :: JError-judyError = JError nullPtr--newtype Frozen a = Frozen a---- FIXME: I don't think this is the right type as I'll be comparing this with--- results which are Ptr Value. const seems to return a number and i didnt found--- a way to create Ptr Value =P---pjerr :: Value---pjerr = (#const PJERR)---- Not sure if it's the best way to get this pointer, but works.--{-# LINE 51 "Judy/Private.hsc" #-}-foreign import ccall unsafe "j_pjerr" pjerr :: Ptr Value--jerr :: Value-jerr = (-1)---- what do we gain from doing that newtype instead of simply doing: type Judy1Array = () ?-newtype Judy1Array = Judy1Array Judy1Array--type Judy1 = Ptr Judy1Array---{-# LINE 62 "Judy/Private.hsc" #-}---{-# LINE 64 "Judy/Private.hsc" #-}---- do we really need this judy1_new? or importing judy1_free?-foreign import ccall unsafe judy1_new :: IO (Ptr Judy1)-foreign import ccall unsafe judy1_free :: Ptr Judy1 -> IO ()--foreign import ccall "&judy1_free" judy1_free_ptr :: FunPtr (Ptr Judy1 -> IO ())---- TODO: import func descriptions from judy manual--foreign import ccall unsafe "Judy1Set" judy1Set :: Ptr Judy1 -> Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1Unset" judy1Unset :: Ptr Judy1 -> Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1Test" judy1Test :: Judy1 -> Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1FreeArray" judy1FreeArray :: Ptr Judy1 -> JError -> IO Value-foreign import ccall unsafe "Judy1Count" judy1Count :: Judy1 -> Value -> Value -> JError -> IO Value--foreign import ccall unsafe "Judy1First" judy1First :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1Next" judy1Next :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1Last" judy1Last :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1Prev" judy1Prev :: Judy1 -> Ptr Value -> JError -> IO CInt--foreign import ccall unsafe "Judy1FirstEmpty" judy1FirstEmpty :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1NextEmpty" judy1NextEmpty :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1LastEmpty" judy1LastEmpty :: Judy1 -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "Judy1PrevEmpty" judy1PrevEmpty :: Judy1 -> Ptr Value -> JError -> IO CInt---newtype JudyLArray = JudyLArray JudyLArray-type JudyL = Ptr JudyLArray---{-# LINE 94 "Judy/Private.hsc" #-}--foreign import ccall "&judyL_free" judyL_free_ptr :: FunPtr (Ptr JudyL -> IO ())--foreign import ccall unsafe "JudyLIns" judyLIns :: Ptr JudyL -> Value -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudyLDel" judyLDel :: Ptr JudyL -> Value -> JError -> IO CInt-foreign import ccall unsafe "JudyLGet" judyLGet :: JudyL -> Value -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudyLCount" judyLCount :: JudyL -> Value -> Value -> JError -> IO Value-foreign import ccall unsafe "JudyLByCount" judyLByCount :: JudyL -> Value -> Ptr Value -> JError -> IO (Ptr Value)--foreign import ccall unsafe "JudyLFreeArray" judyLFreeArray :: Ptr JudyL -> JError -> IO Value-foreign import ccall unsafe "JudyLMemUsed" judyLMemUsed :: JudyL -> IO Value--foreign import ccall unsafe "JudyLFirst" judyLFirst :: JudyL -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudyLNext" judyLNext :: JudyL -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudyLLast" judyLLast :: JudyL -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudyLPrev" judyLPrev :: JudyL -> Ptr Value -> JError -> IO (Ptr Value)--foreign import ccall unsafe "JudyLFirstEmpty" judyLFirstEmpty :: JudyL -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "JudyLNextEmpty" judyLNextEmpty :: JudyL -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "JudyLLastEmpty" judyLLastEmpty :: JudyL -> Ptr Value -> JError -> IO CInt-foreign import ccall unsafe "JudyLPrevEmpty" judyLPrevEmpty :: JudyL -> Ptr Value -> JError -> IO CInt---newtype JudySLArray = JudySLArray JudySLArray-type JudySL = Ptr JudySLArray----{-# LINE 122 "Judy/Private.hsc" #-}---- #def void j_fill(char *p, char x, int len) { int i; for (i=len-1; i!=0; i--) *(p++) = x; p = '\0'; }--{-# LINE 125 "Judy/Private.hsc" #-}----foreign import ccall "j_fill" j_fill :: CString -> CChar -> CInt -> IO ()-foreign import ccall "j_null" j_null :: CString -> IO ()--foreign import ccall "&judySL_free" judySL_free_ptr :: FunPtr (Ptr JudySL -> IO ())--foreign import ccall "JudySLIns" judySLIns :: Ptr JudySL -> CString -> JError -> IO (Ptr Value)-foreign import ccall "JudySLDel" judySLDel :: Ptr JudySL -> CString -> JError -> IO CInt-foreign import ccall "JudySLGet" judySLGet :: JudySL -> CString -> JError -> IO (Ptr Value)-foreign import ccall "JudySLFreeArray" judySLFreeArray :: Ptr JudySL -> JError -> IO Value--foreign import ccall unsafe "JudySLFirst" judySLFirst :: JudySL -> CString -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudySLNext" judySLNext :: JudySL -> CString -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudySLLast" judySLLast :: JudySL -> CString -> JError -> IO (Ptr Value)-foreign import ccall unsafe "JudySLPrev" judySLPrev :: JudySL -> CString -> JError -> IO (Ptr Value)---newtype JudyHSArray = JudyHSArray JudyHSArray-type JudyHS = Ptr JudyHSArray---{-# LINE 146 "Judy/Private.hsc" #-}--{-# LINE 147 "Judy/Private.hsc" #-}----{-# LINE 150 "Judy/Private.hsc" #-}-foreign import ccall "jp_null" jp_null :: Ptr CString -> IO ()----newtype JudyHSIterType = JudyHSIterType JudyHSIterType-type JudyHSIter = Ptr JudyHSIterType--foreign import ccall "&judyHS_free" judyHS_free_ptr :: FunPtr (Ptr JudyHS -> IO ())-foreign import ccall "&judyHSIter_free" judyHSIter_free_ptr :: FunPtr (Ptr JudyHSIter -> IO ())--foreign import ccall "JudyHSIns" judyHSIns :: Ptr JudyHS -> Ptr CChar -> CULong -> JError -> IO (Ptr Value)-foreign import ccall "JudyHSDel" judyHSDel :: Ptr JudyHS -> Ptr CChar -> Value -> JError -> IO CInt-foreign import ccall "JudyHSGet" judyHSGet :: JudyHS -> Ptr CChar -> Value -> IO (Ptr Value)-foreign import ccall "JudyHSFreeArray" judyHSFreeArray :: Ptr JudyHS -> JError -> IO Value--foreign import ccall "JudyHSIterFirst" judyHSIterFirst :: JudyHS -> Ptr JudyHSIter -> Ptr CString -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall "JudyHSIterNext" judyHSIterNext :: JudyHS -> Ptr JudyHSIter -> Ptr CString -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall "JudyHSIterLast" judyHSIterLast :: JudyHS -> Ptr JudyHSIter -> Ptr CString -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall "JudyHSIterPrev" judyHSIterPrev :: JudyHS -> Ptr JudyHSIter -> Ptr CString -> Ptr Value -> JError -> IO (Ptr Value)-foreign import ccall "JudyHSFreeIter" judyHSFreeIter :: Ptr JudyHSIter -> JError -> IO Value-
Judy/Private.hsc view
@@ -4,7 +4,7 @@ import Foreign #if __GLASGOW_HASKELL__ >= 605-import Data.Word+-- import Data.Word #else import GHC.Exts #endif
− Judy/Private_hsc.c
@@ -1,31 +0,0 @@-#include "Private_hsc.h"-#line 6 "Private.hsc"-#if __GLASGOW_HASKELL__ >= 605-#line 8 "Private.hsc"-#else -#line 10 "Private.hsc"-#endif -#line 20 "Private.hsc"-#if __GLASGOW_HASKELL__ >= 605-#line 22 "Private.hsc"-#else -#line 33 "Private.hsc"-#endif -#line 50 "Private.hsc"-void *j_pjerr(void) { return PJERR; }-#line 61 "Private.hsc"-void *judy1_new(void) { return calloc(1,sizeof(void *)); }-#line 63 "Private.hsc"-void judy1_free(void *ptr) { Judy1FreeArray(ptr, PJE0); }-#line 93 "Private.hsc"-void judyL_free(void *ptr) { JudyLFreeArray(ptr, PJE0); }-#line 121 "Private.hsc"-void judySL_free(void *ptr) { JudySLFreeArray(ptr, PJE0); }-#line 124 "Private.hsc"-void j_null(char *p) { p = '\0'; }-#line 145 "Private.hsc"-void judyHS_free(void *ptr) { JudyHSFreeArray(ptr, PJE0); }-#line 146 "Private.hsc"-void judyHSIter_free(void *ptr) { JudyHSFreeIter(ptr, PJE0); }-#line 149 "Private.hsc"-void jp_null(char **p) { p = NULL; }
Judy/Refeable.hs view
@@ -1,10 +1,7 @@-{-# OPTIONS -fallow-undecidable-instances -fallow-incoherent-instances #-}-{-# LANGUAGE MagicHash, UndecidableInstances, IncoherentInstances #-}+{-# LANGUAGE MagicHash, UndecidableInstances, IncoherentInstances, FlexibleInstances #-} module Judy.Refeable ( Refeable (..) ) where-- import Foreign.StablePtr