-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-introduce user-defined comparator
* fixes #5 * Todo: * tweak foreign imports, possibly not all of them need to be 'safe' * maybe it's time to switch to record syntax for options to reduce clutter
- Loading branch information
Showing
3 changed files
with
149 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
-- | Demo custom comparator | ||
|
||
module Main where | ||
|
||
import Control.Monad.IO.Class (liftIO) | ||
import Data.ByteString.Char8 (take) | ||
|
||
import Database.LevelDB | ||
|
||
|
||
comparator :: Comparator | ||
comparator = Comparator compare | ||
|
||
main :: IO () | ||
main = runResourceT $ do | ||
db <- open "/tmp/lvlcmptest" [CreateIfMissing, UseComparator comparator] | ||
|
||
put db [] "zzz" "" | ||
put db [] "yyy" "" | ||
put db [] "xxx" "" | ||
|
||
withIterator db [] $ \iter -> do | ||
iterFirst iter | ||
iterItems iter >>= liftIO . print | ||
|
||
return () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.