anki-tools-0.1.0.0: Tools for interacting with Anki database

Copyright(c) 2016 Al Zohali
LicenseBSD3
MaintainerAl Zohali <zohl@fmap.me>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Anki.Common

Description

Description

Auxiliary functions and types.

Synopsis

Documentation

data AnkiException Source #

The exception is thrown when something goes wrong with this package.

Constructors

WrongFieldType

Thrown when column type is not a text.

NotJson

Thrown when text from database is not a valid json.

WrongJsonFormat

Thrown when json format differs from expected one.

ModelIdInconsistent

Thrown when external and internal ids of model differ.

DeckIdInconsistent

Thrown when external and internal ids of deck differ.

DeckOptionsIdInconsistent

Thrown when external and internal ids of deck options differ.

throwErr :: Typeable a => Field -> AnkiException -> Ok a Source #

Exit from Ok monad.

getTextValue :: Field -> Ok ByteString Source #

Read field as a byte sequence.

getJsonValue :: Field -> Ok Value Source #

Read field as a JSON.

fromDictionary :: Typeable a => (Field -> (Text, Value) -> Ok a) -> Field -> Value -> Ok [a] Source #

Transform a JSON-dictionary to a list of values.

mkEntry :: (Typeable a, FromJSON a, Eq b, Typeable b, FromJSON b) => (a -> b) -> AnkiException -> Field -> (Text, Value) -> Ok a Source #

Transform a single pair from JSON-dictionary of type { id: {id: id, ....} } to a record.

dropPrefixOptions :: Options Source #

Default options used in Aeson typeclasses in this module.