packages feed

couch-hs 0.1.3 → 0.1.4

raw patch · 8 files changed

+31/−34 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Database.CouchDB.ViewServer.Map: type ViewMap a = ViewMapT Parser a
- Database.CouchDB.ViewServer.Reduce: type ViewReduce a = ViewReduceT Parser a
+ Database.CouchDB.ViewServer.Map: data ViewMap a
+ Database.CouchDB.ViewServer.Map: instance Alternative ViewMap
+ Database.CouchDB.ViewServer.Map: instance Applicative ViewMap
+ Database.CouchDB.ViewServer.Map: instance Functor ViewMap
+ Database.CouchDB.ViewServer.Map: instance Monad ViewMap
+ Database.CouchDB.ViewServer.Map: instance MonadParser ViewMap
+ Database.CouchDB.ViewServer.Map: instance MonadPlus ViewMap
+ Database.CouchDB.ViewServer.Reduce: data ViewReduce a
+ Database.CouchDB.ViewServer.Reduce: instance Alternative ViewReduce
+ Database.CouchDB.ViewServer.Reduce: instance Applicative ViewReduce
+ Database.CouchDB.ViewServer.Reduce: instance Functor ViewReduce
+ Database.CouchDB.ViewServer.Reduce: instance Monad ViewReduce
+ Database.CouchDB.ViewServer.Reduce: instance MonadParser ViewReduce
+ Database.CouchDB.ViewServer.Reduce: instance MonadPlus ViewReduce

Files

couch-hs.cabal view
@@ -1,5 +1,5 @@ name: couch-hs-version: 0.1.3+version: 0.1.4 cabal-version: >= 1.6 build-type: Simple license: PublicDomain
source/Database/CouchDB/ViewServer.hs view
@@ -1,5 +1,5 @@ {- |-    This ia a CouchDB view server in and for Haskell. With it, you can define+    This is a CouchDB view server in and for Haskell. With it, you can define     design documents that use Haskell functions to perform map/reduce     operations. Database.CouchDB.ViewServer is just a container; see the     submodules for API documentation.@@ -49,8 +49,10 @@     In addition to the server mode, @couch-hs@ has some special modes to aid     development. CouchDB isn't very good at reporting errors in view functions,     so the following modes can be used to make sure your functions compile-    before installing them into a view. To ensure valid results, be sure to-    match the @couch-hs@ options with those in CouchDB's config file.+    before installing them into a view. These can be run manually, although+    they're especially useful when integrated into your editor. They can also+    serve as a sanity check in your deployment process. To ensure valid results,+    be sure to match the @couch-hs@ options with those in CouchDB's config file.      [@couch-hs \[options\] -M \[CODE|\@PATH\] ...@] Attempt to compile one or     more map functions. Each argument can either be a source string or a path to
source/Database/CouchDB/ViewServer/Internal.hs view
@@ -1,5 +1,3 @@-{-# OPTIONS_HADDOCK hide #-}- module Database.CouchDB.ViewServer.Internal where  import Data.Aeson
source/Database/CouchDB/ViewServer/Main/Server/Command.hs view
@@ -39,6 +39,7 @@                 String "reduce"   -> parseReduce args                 String "rereduce" -> parseRereduce args                 String s          -> fail $ "Unrecognized view command: " ++ unpack s+                _                 -> typeMismatch "view command" value         | otherwise = typeMismatch "view command" value         where             args :: [Value]
source/Database/CouchDB/ViewServer/Map.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-} {-# OPTIONS_HADDOCK prune #-}  module Database.CouchDB.ViewServer.Map@@ -33,6 +33,7 @@ import Data.Text (Text, unpack)  import Control.Applicative+import Control.Monad (Monad, MonadPlus) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Writer (WriterT, tell, execWriterT) @@ -46,18 +47,18 @@     Emit Value Value |     Log LogMessage -type ViewMapT m a = WriterT [MapOutput] m a - {- | The monad within which a map computation takes place. This is a-     transformation of the 'Data.Aeson.Types.Parser' monad, although the precise-     nature and depth of the transformation is an internal detail and subject to-     change. ViewMapT is guaranteed to be an instance of the 'MonadParser'-     class, allowing you to parse JSON structures.+     transformation of the 'Data.Aeson.Types.Parser' monad, which is accessible+     through the 'MonadParser' typeclass. -}-type ViewMap a = ViewMapT Parser a+newtype ViewMap a = ViewMap { runViewMap :: WriterT [MapOutput] Parser a }+    deriving(Monad, Functor, MonadPlus, Applicative, Alternative) +instance MonadParser ViewMap where+    liftParser = ViewMap . lift + {- | The type of your map functions as they are stored in CouchDB. The trivial      example: @@ -80,7 +81,7 @@   execMapFunc :: MapFunc -> Object -> [MapOutput]-execMapFunc mapFunc doc = fromMaybe [] $ parseMaybe execWriterT (runMapFunc mapFunc doc)+execMapFunc mapFunc doc = fromMaybe [] $ parseMaybe execWriterT (runViewMap $ runMapFunc mapFunc doc)   emits :: [MapOutput] -> [MapOutput]@@ -111,7 +112,7 @@ -}   emit :: (ToJSON k, ToJSON v) => k -> v -> ViewMap ()-emit key value = tell [Emit (toJSON key) (toJSON value)]+emit key value = ViewMap $ tell [Emit (toJSON key) (toJSON value)]   {- | Same as 'emit', but with wrapped key and value.@@ -130,4 +131,4 @@      of a failure, look at 'Control.Applicative.Alternative'. -} logMsg :: String -> ViewMap ()-logMsg msg = tell [Log $ LogMessage msg]+logMsg msg = ViewMap $ tell [Log $ LogMessage msg]
source/Database/CouchDB/ViewServer/Parse.hs view
@@ -1,5 +1,3 @@-{-# OPTIONS_HADDOCK hide #-}- module Database.CouchDB.ViewServer.Parse     ( {- |@@ -34,9 +32,6 @@  instance MonadParser Parser where     liftParser = id--instance (Monoid w, MonadParser m) => MonadParser (WriterT w m) where-    liftParser = lift . liftParser   {- | Attempts to parse a JSON value into a given type. This is typically used
source/Database/CouchDB/ViewServer/Reduce.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-} {-# OPTIONS_HADDOCK prune #-}  module Database.CouchDB.ViewServer.Reduce@@ -27,6 +27,8 @@ import Data.Aeson.Types (Value(..), Object, Parser, parseMaybe)  import Control.Applicative+import Control.Monad (Monad, MonadPlus)+import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Writer (WriterT, tell, runWriterT) import qualified Language.Haskell.Interpreter as H @@ -36,18 +38,18 @@  type ReduceOutput = (Value, [LogMessage]) -type ViewReduceT m a = WriterT [LogMessage] m a - {- | The monad within which a reduce computation takes place. This is a-     transformation of the 'Data.Aeson.Types.Parser' monad, although the precise-     nature and depth of the transformation is an internal detail and subject to-     change. ViewReduceT is guaranteed to be an instance of the 'MonadParser'-     class, allowing you to parse JSON structures.+     transformation of the 'Data.Aeson.Types.Parser' monad, which is accessible+     through the 'MonadParser' typeclass. -}-type ViewReduce a = ViewReduceT Parser a+newtype ViewReduce a = ViewReduce { runViewReduce :: WriterT [LogMessage] Parser a }+    deriving(Monad, Functor, MonadPlus, Applicative, Alternative) +instance MonadParser ViewReduce where+    liftParser = ViewReduce . lift + {- | The type of your reduce functions as they are stored in CouchDB. The trivial      example: @@ -71,7 +73,7 @@   execReduceFunc :: ReduceFunc -> [Value] -> [Value] -> Bool -> ReduceOutput-execReduceFunc reduceFunc keys values rereduce = fromMaybe (Null, []) $ parseMaybe runWriterT (runReduceFunc reduceFunc keys values rereduce)+execReduceFunc reduceFunc keys values rereduce = fromMaybe (Null, []) $ parseMaybe runWriterT (runViewReduce $ runReduceFunc reduceFunc keys values rereduce)   {- | Send a log message to the CouchDB server. Note that log messages are only@@ -79,4 +81,4 @@      of a failure, look at 'Control.Applicative.Alternative'. -} logMsg :: String -> ViewReduce ()-logMsg msg = tell [LogMessage msg]+logMsg msg = ViewReduce $ tell [LogMessage msg]
source/server.hs view
@@ -1,5 +1,3 @@-#!/usr/bin/env runhaskell- module Main where