- type ReduceSignature a = [Value] -> [Value] -> Bool -> ViewReduce a
- data ViewReduce a
- class Monad m => MonadParser m where
- liftParser :: Parser a -> m a
- parseJSON :: (MonadParser m, FromJSON a) => Value -> m a
- parseJSONList :: (MonadParser m, FromJSON a) => [Value] -> m [a]
- (.:) :: (MonadParser m, FromJSON a) => Object -> Text -> m a
- (.:?) :: (MonadParser m, FromJSON a) => Object -> Text -> m (Maybe a)
- (.=) :: ToJSON a => Text -> a -> Pair
- object :: [Pair] -> Value
- data Value
- logMsg :: String -> ViewReduce ()
Map Functions
type ReduceSignature a = [Value] -> [Value] -> Bool -> ViewReduce aSource
The type of your reduce functions as they are stored in CouchDB. The trivial example:
\keys values rereduce -> return Null
data ViewReduce a Source
The monad within which a reduce computation takes place. This is a
transformation of the Parser
monad, which is accessible
through the MonadParser
typeclass.
JSON Parsing
JSON parsers lifted into our view monads. This also exports one or two
useful symbols from Data.Aeson.Types
.
class Monad m => MonadParser m whereSource
Like MonadIO, but for Parser
. This allows JSON parsing
operations to be lifted into our various view monads.
liftParser :: Parser a -> m aSource
parseJSON :: (MonadParser m, FromJSON a) => Value -> m aSource
Attempts to parse a JSON value into a given type. This is typically used with a type annotation to indicate the target type. If the value can not be parsed into that type, the entire computation will fail.
parseJSONList :: (MonadParser m, FromJSON a) => [Value] -> m [a]Source
Applies parseJSON
to a list of values. This is commonly used with the
reduce function arguments.
(.:) :: (MonadParser m, FromJSON a) => Object -> Text -> m aSource
Parses a required field of an object. If the field is not present, or the value can not be parsed into the target type, the computation will fail.
(.:?) :: (MonadParser m, FromJSON a) => Object -> Text -> m (Maybe a)Source
Parses an optional field of an object. This will not halt the computation on failure.
data Value
A JSON value represented as a Haskell value.
ViewReduce Monads
logMsg :: String -> ViewReduce ()Source
Send a log message to the CouchDB server. Note that log messages are only
sent if the computation succeeds. If you want to log a message in the event
of a failure, look at Alternative
.