Skip to content

Commit

Permalink
Updated to use conduit
Browse files Browse the repository at this point in the history
  • Loading branch information
bitonic committed Feb 25, 2012
1 parent 03e0a44 commit b2eab7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Suggest.hs
Expand Up @@ -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)
Expand Down Expand Up @@ -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")]
Expand All @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion resources/search.html
Expand Up @@ -109,7 +109,7 @@
} else {
span.append(word);
}
if (i < diff.words.length - 1) {
if (i < diff.words.length - 1) {
span.append('&nbsp;');
}
}
Expand Down
2 changes: 1 addition & 1 deletion suggest.cabal
Expand Up @@ -20,7 +20,7 @@ executable suggest
build-depends: base >= 4 && < 5
, warp
, wai
, enumerator
, conduit
, blaze-builder
, http-types
, utf8-string
Expand Down

0 comments on commit b2eab7c

Please sign in to comment.