Permalink
Browse files

Updated to use conduit

  • Loading branch information...
1 parent 03e0a44 commit b2eab7c8f3acf136e6c169480c1efcb63fa03caa @bitonic committed Feb 25, 2012
Showing with 5 additions and 7 deletions.
  1. +3 −5 Suggest.hs
  2. +1 −1 resources/search.html
  3. +1 −1 suggest.cabal
View
@@ -3,10 +3,9 @@ module Main where
import Blaze.ByteString.Builder.Char.Utf8 (fromString)
import Control.Monad.Trans (lift)
-import Data.ByteString (ByteString)
import Data.ByteString.UTF8 (toString)
import Data.Char (toLower)
-import Data.Enumerator (Iteratee)
+import Data.Conduit (ResourceT)
import Data.IORef
import Data.List (intercalate, sortBy)
import Data.Ord (comparing)
@@ -45,7 +44,7 @@ lookupSuggestCache dict cache w = do
atomicModifyIORef cache ((, ()) . insert w ws)
return ws
-suggest :: Dictionary -> IORef SuggestCache -> String -> Iteratee ByteString IO Response
+suggest :: Dictionary -> IORef SuggestCache -> String -> ResourceT IO Response
suggest dict cache w = do
ws <- lift $ lookupSuggestCache dict cache w
return $ ResponseBuilder status200 [("Content-Type", "application/json")]
@@ -68,8 +67,7 @@ lookupCorrectorCache dict cache w = do
edits1 = process . edits . wildList $ w
edits2 = process . concatMap edits . edits . wildList $ w
-
-correct :: Dictionary -> IORef CorrectorCache -> [String] -> Iteratee ByteString IO Response
+correct :: Dictionary -> IORef CorrectorCache -> [String] -> ResourceT IO Response
correct dict cache ws = do
wm <- lift . mapM (lookupCorrectorCache dict cache) $ ws
return $ ResponseBuilder status200 [("Content-Type", "application/json")]
View
@@ -109,7 +109,7 @@
} else {
span.append(word);
}
- if (i < diff.words.length - 1) {
+ if (i < diff.words.length - 1) {
span.append('&nbsp;');
}
}
View
@@ -20,7 +20,7 @@ executable suggest
build-depends: base >= 4 && < 5
, warp
, wai
- , enumerator
+ , conduit
, blaze-builder
, http-types
, utf8-string

0 comments on commit b2eab7c

Please sign in to comment.