{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE CPP                        #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE ExistentialQuantification  #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE IncoherentInstances        #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE PatternGuards              #-}
{-# LANGUAGE ScopedTypeVariables        #-}
#if MIN_VERSION_base(4,8,0)
#define OVERLAPS {-# OVERLAPPING #-}
#else
{-# LANGUAGE OverlappingInstances       #-}
#define OVERLAPS
#endif
-----------------------------------------------------------------------------
-- |
-- Module      :  Text.CSL.Reference
-- Copyright   :  (c) Andrea Rossato
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  Andrea Rossato <andrea.rossato@unitn.it>
-- Stability   :  unstable
-- Portability :  unportable
--
-- The Reference type
--
-----------------------------------------------------------------------------

module Text.CSL.Reference ( Literal(..)
                          , Value(..)
                          , ReferenceMap
                          , mkRefMap
                          , fromValue
                          , isValueSet
                          , Empty(..)
                          , Season(..)
                          , seasonToInt
                          , RefDate(..)
                          , handleLiteral
                          , toDatePart
                          , setCirca
                          , RefType(..)
                          , CNum(..)
                          , CLabel(..)
                          , Reference(..)
                          , emptyReference
                          , numericVars
                          , getReference
                          , processCites
                          , setPageFirst
                          , setNearNote
                          , parseEDTFDate
                          )
where

import Prelude
import           Control.Applicative ((<|>))
import           Control.Monad       (guard, mplus, msum)
import           Data.Aeson          hiding (Value)
import qualified Data.Aeson          as Aeson
import           Data.Aeson.Types    (Parser)
import           Data.Char           (isDigit, toLower, isPunctuation)
import           Data.Either         (lefts, rights)
import           Data.Generics       hiding (Generic)
import qualified Data.HashMap.Strict as H
import           Data.List           (find, elemIndex)
import           Data.List.Split     (splitWhen)
import           Data.Maybe          (fromMaybe, isNothing)
import           Data.String
import           Data.Text           (Text)
import qualified Data.Text           as T
import qualified Data.Vector         as V
import           Data.Yaml.Builder   (ToYaml (..))
import qualified Data.Yaml.Builder   as Y
import           GHC.Generics        (Generic)
import           Text.CSL.Style      hiding (Number)
import           Text.CSL.Util       (camelize, capitalize, inlinesToString,
                                      mapping', parseBool, parseInt, parseMaybeInt,
                                      parseString, readNum, safeRead, trim,
                                      uncamelize, AddYaml(..), splitStrWhen)
import           Text.Pandoc         (Inline (Str))
import qualified Text.Parsec         as P
import qualified Text.Parsec.String  as P

newtype Literal = Literal { Literal -> String
unLiteral :: String }
  deriving ( Int -> Literal -> ShowS
[Literal] -> ShowS
Literal -> String
(Int -> Literal -> ShowS)
-> (Literal -> String) -> ([Literal] -> ShowS) -> Show Literal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Literal] -> ShowS
$cshowList :: [Literal] -> ShowS
show :: Literal -> String
$cshow :: Literal -> String
showsPrec :: Int -> Literal -> ShowS
$cshowsPrec :: Int -> Literal -> ShowS
Show, ReadPrec [Literal]
ReadPrec Literal
Int -> ReadS Literal
ReadS [Literal]
(Int -> ReadS Literal)
-> ReadS [Literal]
-> ReadPrec Literal
-> ReadPrec [Literal]
-> Read Literal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Literal]
$creadListPrec :: ReadPrec [Literal]
readPrec :: ReadPrec Literal
$creadPrec :: ReadPrec Literal
readList :: ReadS [Literal]
$creadList :: ReadS [Literal]
readsPrec :: Int -> ReadS Literal
$creadsPrec :: Int -> ReadS Literal
Read, Literal -> Literal -> Bool
(Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool) -> Eq Literal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Literal -> Literal -> Bool
$c/= :: Literal -> Literal -> Bool
== :: Literal -> Literal -> Bool
$c== :: Literal -> Literal -> Bool
Eq, Typeable Literal
DataType
Constr
Typeable Literal =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Literal -> c Literal)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Literal)
-> (Literal -> Constr)
-> (Literal -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Literal))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Literal))
-> ((forall b. Data b => b -> b) -> Literal -> Literal)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Literal -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Literal -> r)
-> (forall u. (forall d. Data d => d -> u) -> Literal -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Literal -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Literal -> m Literal)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Literal -> m Literal)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Literal -> m Literal)
-> Data Literal
Literal -> DataType
Literal -> Constr
(forall b. Data b => b -> b) -> Literal -> Literal
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Literal -> c Literal
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Literal
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Literal -> u
forall u. (forall d. Data d => d -> u) -> Literal -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Literal -> m Literal
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Literal -> m Literal
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Literal
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Literal -> c Literal
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Literal)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Literal)
$cLiteral :: Constr
$tLiteral :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Literal -> m Literal
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Literal -> m Literal
gmapMp :: (forall d. Data d => d -> m d) -> Literal -> m Literal
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Literal -> m Literal
gmapM :: (forall d. Data d => d -> m d) -> Literal -> m Literal
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Literal -> m Literal
gmapQi :: Int -> (forall d. Data d => d -> u) -> Literal -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Literal -> u
gmapQ :: (forall d. Data d => d -> u) -> Literal -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Literal -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Literal -> r
gmapT :: (forall b. Data b => b -> b) -> Literal -> Literal
$cgmapT :: (forall b. Data b => b -> b) -> Literal -> Literal
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Literal)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Literal)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Literal)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Literal)
dataTypeOf :: Literal -> DataType
$cdataTypeOf :: Literal -> DataType
toConstr :: Literal -> Constr
$ctoConstr :: Literal -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Literal
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Literal
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Literal -> c Literal
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Literal -> c Literal
$cp1Data :: Typeable Literal
Data, Typeable, b -> Literal -> Literal
NonEmpty Literal -> Literal
Literal -> Literal -> Literal
(Literal -> Literal -> Literal)
-> (NonEmpty Literal -> Literal)
-> (forall b. Integral b => b -> Literal -> Literal)
-> Semigroup Literal
forall b. Integral b => b -> Literal -> Literal
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Literal -> Literal
$cstimes :: forall b. Integral b => b -> Literal -> Literal
sconcat :: NonEmpty Literal -> Literal
$csconcat :: NonEmpty Literal -> Literal
<> :: Literal -> Literal -> Literal
$c<> :: Literal -> Literal -> Literal
Semigroup, Semigroup Literal
Literal
Semigroup Literal =>
Literal
-> (Literal -> Literal -> Literal)
-> ([Literal] -> Literal)
-> Monoid Literal
[Literal] -> Literal
Literal -> Literal -> Literal
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [Literal] -> Literal
$cmconcat :: [Literal] -> Literal
mappend :: Literal -> Literal -> Literal
$cmappend :: Literal -> Literal -> Literal
mempty :: Literal
$cmempty :: Literal
$cp1Monoid :: Semigroup Literal
Monoid, (forall x. Literal -> Rep Literal x)
-> (forall x. Rep Literal x -> Literal) -> Generic Literal
forall x. Rep Literal x -> Literal
forall x. Literal -> Rep Literal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Literal x -> Literal
$cfrom :: forall x. Literal -> Rep Literal x
Generic )

instance AddYaml Literal
  where x :: Text
x &= :: Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= (Literal y :: String
y) = Text
x Text -> Text -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= (String -> Text
T.pack String
y)

instance FromJSON Literal where
  parseJSON :: Value -> Parser Literal
parseJSON v :: Value
v             = String -> Literal
Literal (String -> Literal) -> Parser String -> Parser Literal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Value -> Parser String
parseString Value
v

instance ToJSON Literal where
  toJSON :: Literal -> Value
toJSON = String -> Value
forall a. ToJSON a => a -> Value
toJSON (String -> Value) -> (Literal -> String) -> Literal -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Literal -> String
unLiteral

instance ToYaml Literal where
  toYaml :: Literal -> YamlBuilder
toYaml = Text -> YamlBuilder
Y.string (Text -> YamlBuilder)
-> (Literal -> Text) -> Literal -> YamlBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (Literal -> String) -> Literal -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Literal -> String
unLiteral

instance IsString Literal where
  fromString :: String -> Literal
fromString = String -> Literal
Literal

-- | An existential type to wrap the different types a 'Reference' is
-- made of. This way we can create a map to make queries easier.
data Value = forall a . Data a => Value a

-- for debuging
instance Show Value where
    show :: Value -> String
show (Value a :: a
a) = a -> String
forall a. Data a => a -> String
gshow a
a

type ReferenceMap = [(String, Value)]

mkRefMap :: Maybe Reference -> ReferenceMap
mkRefMap :: Maybe Reference -> ReferenceMap
mkRefMap Nothing  = []
mkRefMap (Just r :: Reference
r) = [String] -> [Value] -> ReferenceMap
forall a b. [a] -> [b] -> [(a, b)]
zip [String]
fields ((forall d. Data d => d -> Value) -> Reference -> [Value]
forall a u. Data a => (forall d. Data d => d -> u) -> a -> [u]
gmapQ forall d. Data d => d -> Value
Value Reference
r)
      where fields :: [String]
fields = ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ShowS
uncamelize ([String] -> [String])
-> (Reference -> [String]) -> Reference -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Constr -> [String]
constrFields (Constr -> [String])
-> (Reference -> Constr) -> Reference -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reference -> Constr
forall a. Data a => a -> Constr
toConstr (Reference -> [String]) -> Reference -> [String]
forall a b. (a -> b) -> a -> b
$ Reference
r

fromValue :: Data a => Value -> Maybe a
fromValue :: Value -> Maybe a
fromValue (Value a :: a
a) = a -> Maybe a
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast a
a

isValueSet :: Value -> Bool
isValueSet :: Value -> Bool
isValueSet val :: Value
val
    | Just v :: Literal
v <- Value -> Maybe Literal
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe Literal   = Literal
v Literal -> Literal -> Bool
forall a. Eq a => a -> a -> Bool
/= Literal
forall a. Monoid a => a
mempty
    | Just v :: String
v <- Value -> Maybe String
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe String    = String
v String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
forall a. Monoid a => a
mempty
    | Just v :: Formatted
v <- Value -> Maybe Formatted
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe Formatted = Formatted
v Formatted -> Formatted -> Bool
forall a. Eq a => a -> a -> Bool
/= Formatted
forall a. Monoid a => a
mempty
    | Just v :: [Agent]
v <- Value -> Maybe [Agent]
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe [Agent]   = [Agent]
v [Agent] -> [Agent] -> Bool
forall a. Eq a => a -> a -> Bool
/= []
    | Just v :: [RefDate]
v <- Value -> Maybe [RefDate]
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe [RefDate] = [RefDate]
v [RefDate] -> [RefDate] -> Bool
forall a. Eq a => a -> a -> Bool
/= []
    | Just v :: Int
v <- Value -> Maybe Int
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe Int       = Int
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= 0
    | Just v :: CNum
v <- Value -> Maybe CNum
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe CNum      = CNum
v CNum -> CNum -> Bool
forall a. Eq a => a -> a -> Bool
/= 0
    | Just v :: CLabel
v <- Value -> Maybe CLabel
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe CLabel    = CLabel
v CLabel -> CLabel -> Bool
forall a. Eq a => a -> a -> Bool
/= CLabel
forall a. Monoid a => a
mempty
    | Just _ <- Value -> Maybe Empty
forall a. Data a => Value -> Maybe a
fromValue Value
val :: Maybe Empty     = Bool
True
    | Bool
otherwise = Bool
False

data Empty = Empty deriving ( Typeable, Typeable Empty
DataType
Constr
Typeable Empty =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Empty -> c Empty)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Empty)
-> (Empty -> Constr)
-> (Empty -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Empty))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Empty))
-> ((forall b. Data b => b -> b) -> Empty -> Empty)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r)
-> (forall u. (forall d. Data d => d -> u) -> Empty -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Empty -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Empty -> m Empty)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Empty -> m Empty)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Empty -> m Empty)
-> Data Empty
Empty -> DataType
Empty -> Constr
(forall b. Data b => b -> b) -> Empty -> Empty
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty -> c Empty
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Empty
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Empty -> u
forall u. (forall d. Data d => d -> u) -> Empty -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Empty -> m Empty
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Empty -> m Empty
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Empty
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty -> c Empty
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Empty)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Empty)
$cEmpty :: Constr
$tEmpty :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Empty -> m Empty
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Empty -> m Empty
gmapMp :: (forall d. Data d => d -> m d) -> Empty -> m Empty
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Empty -> m Empty
gmapM :: (forall d. Data d => d -> m d) -> Empty -> m Empty
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Empty -> m Empty
gmapQi :: Int -> (forall d. Data d => d -> u) -> Empty -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Empty -> u
gmapQ :: (forall d. Data d => d -> u) -> Empty -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Empty -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Empty -> r
gmapT :: (forall b. Data b => b -> b) -> Empty -> Empty
$cgmapT :: (forall b. Data b => b -> b) -> Empty -> Empty
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Empty)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Empty)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Empty)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Empty)
dataTypeOf :: Empty -> DataType
$cdataTypeOf :: Empty -> DataType
toConstr :: Empty -> Constr
$ctoConstr :: Empty -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Empty
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Empty
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty -> c Empty
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Empty -> c Empty
$cp1Data :: Typeable Empty
Data, (forall x. Empty -> Rep Empty x)
-> (forall x. Rep Empty x -> Empty) -> Generic Empty
forall x. Rep Empty x -> Empty
forall x. Empty -> Rep Empty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Empty x -> Empty
$cfrom :: forall x. Empty -> Rep Empty x
Generic )

data Season = Spring | Summer | Autumn | Winter | RawSeason String
     deriving (Int -> Season -> ShowS
[Season] -> ShowS
Season -> String
(Int -> Season -> ShowS)
-> (Season -> String) -> ([Season] -> ShowS) -> Show Season
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Season] -> ShowS
$cshowList :: [Season] -> ShowS
show :: Season -> String
$cshow :: Season -> String
showsPrec :: Int -> Season -> ShowS
$cshowsPrec :: Int -> Season -> ShowS
Show, ReadPrec [Season]
ReadPrec Season
Int -> ReadS Season
ReadS [Season]
(Int -> ReadS Season)
-> ReadS [Season]
-> ReadPrec Season
-> ReadPrec [Season]
-> Read Season
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Season]
$creadListPrec :: ReadPrec [Season]
readPrec :: ReadPrec Season
$creadPrec :: ReadPrec Season
readList :: ReadS [Season]
$creadList :: ReadS [Season]
readsPrec :: Int -> ReadS Season
$creadsPrec :: Int -> ReadS Season
Read, Season -> Season -> Bool
(Season -> Season -> Bool)
-> (Season -> Season -> Bool) -> Eq Season
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Season -> Season -> Bool
$c/= :: Season -> Season -> Bool
== :: Season -> Season -> Bool
$c== :: Season -> Season -> Bool
Eq, Typeable, Typeable Season
DataType
Constr
Typeable Season =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Season -> c Season)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Season)
-> (Season -> Constr)
-> (Season -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Season))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Season))
-> ((forall b. Data b => b -> b) -> Season -> Season)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Season -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Season -> r)
-> (forall u. (forall d. Data d => d -> u) -> Season -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Season -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Season -> m Season)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Season -> m Season)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Season -> m Season)
-> Data Season
Season -> DataType
Season -> Constr
(forall b. Data b => b -> b) -> Season -> Season
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Season -> c Season
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Season
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Season -> u
forall u. (forall d. Data d => d -> u) -> Season -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Season -> m Season
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Season -> m Season
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Season
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Season -> c Season
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Season)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Season)
$cRawSeason :: Constr
$cWinter :: Constr
$cAutumn :: Constr
$cSummer :: Constr
$cSpring :: Constr
$tSeason :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Season -> m Season
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Season -> m Season
gmapMp :: (forall d. Data d => d -> m d) -> Season -> m Season
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Season -> m Season
gmapM :: (forall d. Data d => d -> m d) -> Season -> m Season
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Season -> m Season
gmapQi :: Int -> (forall d. Data d => d -> u) -> Season -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Season -> u
gmapQ :: (forall d. Data d => d -> u) -> Season -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Season -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Season -> r
gmapT :: (forall b. Data b => b -> b) -> Season -> Season
$cgmapT :: (forall b. Data b => b -> b) -> Season -> Season
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Season)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Season)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Season)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Season)
dataTypeOf :: Season -> DataType
$cdataTypeOf :: Season -> DataType
toConstr :: Season -> Constr
$ctoConstr :: Season -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Season
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Season
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Season -> c Season
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Season -> c Season
$cp1Data :: Typeable Season
Data, (forall x. Season -> Rep Season x)
-> (forall x. Rep Season x -> Season) -> Generic Season
forall x. Rep Season x -> Season
forall x. Season -> Rep Season x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Season x -> Season
$cfrom :: forall x. Season -> Rep Season x
Generic)

instance ToYaml Season where
  toYaml :: Season -> YamlBuilder
toYaml Spring = Int -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (1 :: Int)
  toYaml Summer = Int -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (2 :: Int)
  toYaml Autumn = Int -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (3 :: Int)
  toYaml Winter = Int -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (4 :: Int)
  toYaml (RawSeason s :: String
s) = Text -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (String -> Text
T.pack String
s)

seasonToInt :: Season -> Maybe Int
seasonToInt :: Season -> Maybe Int
seasonToInt Spring = Int -> Maybe Int
forall a. a -> Maybe a
Just 1
seasonToInt Summer = Int -> Maybe Int
forall a. a -> Maybe a
Just 2
seasonToInt Autumn = Int -> Maybe Int
forall a. a -> Maybe a
Just 3
seasonToInt Winter = Int -> Maybe Int
forall a. a -> Maybe a
Just 4
seasonToInt _      = Maybe Int
forall a. Maybe a
Nothing

intToSeason :: Int -> Maybe Season
intToSeason :: Int -> Maybe Season
intToSeason 1 = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Spring
intToSeason 2 = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Summer
intToSeason 3 = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Autumn
intToSeason 4 = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Winter
intToSeason _  = Maybe Season
forall a. Maybe a
Nothing

pseudoMonthToSeason :: Int -> Maybe Season
pseudoMonthToSeason :: Int -> Maybe Season
pseudoMonthToSeason n :: Int
n
  | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 13 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 16 = Int -> Maybe Season
intToSeason (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- 12)
  | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 21 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 24 = Int -> Maybe Season
intToSeason (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- 20)
  | Bool
otherwise          = Maybe Season
forall a. Maybe a
Nothing

-- | Parse JSON value as Maybe Season.
parseMaybeSeason :: Maybe Aeson.Value -> Parser (Maybe Season)
parseMaybeSeason :: Maybe Value -> Parser (Maybe Season)
parseMaybeSeason Nothing = Maybe Season -> Parser (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Season
forall a. Maybe a
Nothing
parseMaybeSeason (Just x :: Value
x) = do
  Maybe Int
mbn <- Maybe Value -> Parser (Maybe Int)
parseMaybeInt (Value -> Maybe Value
forall a. a -> Maybe a
Just Value
x) Parser (Maybe Int) -> Parser (Maybe Int) -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Int -> Parser (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Int
forall a. Maybe a
Nothing
  case Maybe Int
mbn of
       Just n :: Int
n -> case Int -> Maybe Season
intToSeason Int
n of
                      Just s :: Season
s  -> Maybe Season -> Parser (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Season -> Parser (Maybe Season))
-> Maybe Season -> Parser (Maybe Season)
forall a b. (a -> b) -> a -> b
$ Season -> Maybe Season
forall a. a -> Maybe a
Just Season
s
                      Nothing -> String -> Parser (Maybe Season)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (Maybe Season))
-> String -> Parser (Maybe Season)
forall a b. (a -> b) -> a -> b
$ "Could not read season: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
       Nothing -> do
         String
s <- Value -> Parser String
parseString Value
x
         if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
s
            then Maybe Season -> Parser (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Season
forall a. Maybe a
Nothing
            else Maybe Season -> Parser (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Season -> Parser (Maybe Season))
-> Maybe Season -> Parser (Maybe Season)
forall a b. (a -> b) -> a -> b
$ Season -> Maybe Season
forall a. a -> Maybe a
Just (Season -> Maybe Season) -> Season -> Maybe Season
forall a b. (a -> b) -> a -> b
$ String -> Season
RawSeason String
s

data RefDate =
    RefDate { RefDate -> Maybe Int
year   :: Maybe Int
            , RefDate -> Maybe Int
month  :: Maybe Int
            , RefDate -> Maybe Season
season :: Maybe Season
            , RefDate -> Maybe Int
day    :: Maybe Int
            , RefDate -> Literal
other  :: Literal
            , RefDate -> Bool
circa  :: Bool
            } deriving ( Int -> RefDate -> ShowS
[RefDate] -> ShowS
RefDate -> String
(Int -> RefDate -> ShowS)
-> (RefDate -> String) -> ([RefDate] -> ShowS) -> Show RefDate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RefDate] -> ShowS
$cshowList :: [RefDate] -> ShowS
show :: RefDate -> String
$cshow :: RefDate -> String
showsPrec :: Int -> RefDate -> ShowS
$cshowsPrec :: Int -> RefDate -> ShowS
Show, ReadPrec [RefDate]
ReadPrec RefDate
Int -> ReadS RefDate
ReadS [RefDate]
(Int -> ReadS RefDate)
-> ReadS [RefDate]
-> ReadPrec RefDate
-> ReadPrec [RefDate]
-> Read RefDate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RefDate]
$creadListPrec :: ReadPrec [RefDate]
readPrec :: ReadPrec RefDate
$creadPrec :: ReadPrec RefDate
readList :: ReadS [RefDate]
$creadList :: ReadS [RefDate]
readsPrec :: Int -> ReadS RefDate
$creadsPrec :: Int -> ReadS RefDate
Read, RefDate -> RefDate -> Bool
(RefDate -> RefDate -> Bool)
-> (RefDate -> RefDate -> Bool) -> Eq RefDate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RefDate -> RefDate -> Bool
$c/= :: RefDate -> RefDate -> Bool
== :: RefDate -> RefDate -> Bool
$c== :: RefDate -> RefDate -> Bool
Eq, Typeable, Typeable RefDate
DataType
Constr
Typeable RefDate =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RefDate -> c RefDate)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RefDate)
-> (RefDate -> Constr)
-> (RefDate -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RefDate))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefDate))
-> ((forall b. Data b => b -> b) -> RefDate -> RefDate)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RefDate -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RefDate -> r)
-> (forall u. (forall d. Data d => d -> u) -> RefDate -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RefDate -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RefDate -> m RefDate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RefDate -> m RefDate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RefDate -> m RefDate)
-> Data RefDate
RefDate -> DataType
RefDate -> Constr
(forall b. Data b => b -> b) -> RefDate -> RefDate
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefDate -> c RefDate
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefDate
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RefDate -> u
forall u. (forall d. Data d => d -> u) -> RefDate -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RefDate -> m RefDate
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefDate -> m RefDate
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefDate
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefDate -> c RefDate
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RefDate)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefDate)
$cRefDate :: Constr
$tRefDate :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RefDate -> m RefDate
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefDate -> m RefDate
gmapMp :: (forall d. Data d => d -> m d) -> RefDate -> m RefDate
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefDate -> m RefDate
gmapM :: (forall d. Data d => d -> m d) -> RefDate -> m RefDate
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RefDate -> m RefDate
gmapQi :: Int -> (forall d. Data d => d -> u) -> RefDate -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RefDate -> u
gmapQ :: (forall d. Data d => d -> u) -> RefDate -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RefDate -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefDate -> r
gmapT :: (forall b. Data b => b -> b) -> RefDate -> RefDate
$cgmapT :: (forall b. Data b => b -> b) -> RefDate -> RefDate
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefDate)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefDate)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RefDate)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RefDate)
dataTypeOf :: RefDate -> DataType
$cdataTypeOf :: RefDate -> DataType
toConstr :: RefDate -> Constr
$ctoConstr :: RefDate -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefDate
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefDate
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefDate -> c RefDate
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefDate -> c RefDate
$cp1Data :: Typeable RefDate
Data, (forall x. RefDate -> Rep RefDate x)
-> (forall x. Rep RefDate x -> RefDate) -> Generic RefDate
forall x. Rep RefDate x -> RefDate
forall x. RefDate -> Rep RefDate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RefDate x -> RefDate
$cfrom :: forall x. RefDate -> Rep RefDate x
Generic )

instance AddYaml RefDate where
  _ &= :: Text -> RefDate -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= (RefDate Nothing Nothing Nothing Nothing o :: Literal
o _) | Literal
o Literal -> Literal -> Bool
forall a. Eq a => a -> a -> Bool
== Literal
forall a. Monoid a => a
mempty = [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> a
id
  x :: Text
x &= y :: RefDate
y = Text
x Text -> RefDate -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate
y

instance FromJSON RefDate where
  parseJSON :: Value -> Parser RefDate
parseJSON (Array v :: Array
v) = RefDate -> RefDate
handlePseudoMonths (RefDate -> RefDate) -> Parser RefDate -> Parser RefDate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
     case Value -> Result [Maybe Value]
forall a. FromJSON a => Value -> Result a
fromJSON (Array -> Value
Array Array
v) of
          Success [y :: Maybe Value
y]     -> Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Maybe Int
 -> Maybe Int
 -> Maybe Season
 -> Maybe Int
 -> Literal
 -> Bool
 -> RefDate)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
y Parser
  (Maybe Int
   -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int)
-> Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
                    Maybe Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
forall a. Maybe a
Nothing Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Season)
-> Parser (Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Season -> Parser (Maybe Season)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Season
forall a. Maybe a
Nothing Parser (Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int) -> Parser (Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
forall a. Maybe a
Nothing Parser (Literal -> Bool -> RefDate)
-> Parser Literal -> Parser (Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
                    Literal -> Parser Literal
forall (f :: * -> *) a. Applicative f => a -> f a
pure "" Parser (Bool -> RefDate) -> Parser Bool -> Parser RefDate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
          Success [y :: Maybe Value
y,m :: Maybe Value
m]   -> Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Maybe Int
 -> Maybe Int
 -> Maybe Season
 -> Maybe Int
 -> Literal
 -> Bool
 -> RefDate)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
y Parser
  (Maybe Int
   -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int)
-> Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
m Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Season)
-> Parser (Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
                    Maybe Season -> Parser (Maybe Season)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Season
forall a. Maybe a
Nothing Parser (Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int) -> Parser (Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
forall a. Maybe a
Nothing Parser (Literal -> Bool -> RefDate)
-> Parser Literal -> Parser (Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Literal -> Parser Literal
forall (f :: * -> *) a. Applicative f => a -> f a
pure "" Parser (Bool -> RefDate) -> Parser Bool -> Parser RefDate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
          Success [y :: Maybe Value
y,m :: Maybe Value
m,d :: Maybe Value
d] -> Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Maybe Int
 -> Maybe Int
 -> Maybe Season
 -> Maybe Int
 -> Literal
 -> Bool
 -> RefDate)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
y Parser
  (Maybe Int
   -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int)
-> Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
m Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Season)
-> Parser (Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
                    Maybe Season -> Parser (Maybe Season)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Season
forall a. Maybe a
Nothing Parser (Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int) -> Parser (Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Value -> Parser (Maybe Int)
parseMaybeInt Maybe Value
d Parser (Literal -> Bool -> RefDate)
-> Parser Literal -> Parser (Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Literal -> Parser Literal
forall (f :: * -> *) a. Applicative f => a -> f a
pure "" Parser (Bool -> RefDate) -> Parser Bool -> Parser RefDate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
          Error e :: String
e         -> String -> Parser RefDate
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser RefDate) -> String -> Parser RefDate
forall a b. (a -> b) -> a -> b
$ "Could not parse RefDate: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
e
          _               -> String -> Parser RefDate
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Could not parse RefDate"
     where handlePseudoMonths :: RefDate -> RefDate
handlePseudoMonths r :: RefDate
r =
              case RefDate -> Maybe Int
month RefDate
r Maybe Int -> (Int -> Maybe Season) -> Maybe Season
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Maybe Season
pseudoMonthToSeason of
                   Just s :: Season
s  -> RefDate
r{ month :: Maybe Int
month = Maybe Int
forall a. Maybe a
Nothing, season :: Maybe Season
season = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
s }
                   Nothing -> RefDate
r
  parseJSON (Object v :: Object
v) = Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Maybe Int
 -> Maybe Int
 -> Maybe Season
 -> Maybe Int
 -> Literal
 -> Bool
 -> RefDate)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
              (Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "year" Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe Int)) -> Parser (Maybe Int)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Maybe Value -> Parser (Maybe Int)
parseMaybeInt) Parser
  (Maybe Int
   -> Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int)
-> Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
              (Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "month" Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe Int)) -> Parser (Maybe Int)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Maybe Value -> Parser (Maybe Int)
parseMaybeInt) Parser (Maybe Season -> Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Season)
-> Parser (Maybe Int -> Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
              (Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "season" Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe Season)) -> Parser (Maybe Season)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Maybe Value -> Parser (Maybe Season)
parseMaybeSeason) Parser (Maybe Int -> Literal -> Bool -> RefDate)
-> Parser (Maybe Int) -> Parser (Literal -> Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
              (Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "day" Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe Int)) -> Parser (Maybe Int)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Maybe Value -> Parser (Maybe Int)
parseMaybeInt) Parser (Literal -> Bool -> RefDate)
-> Parser Literal -> Parser (Bool -> RefDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
              Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "literal" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser (Bool -> RefDate) -> Parser Bool -> Parser RefDate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
              ((Object
v Object -> Text -> Parser Value
forall a. FromJSON a => Object -> Text -> Parser a
.: "circa" Parser Value -> (Value -> Parser Bool) -> Parser Bool
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Value -> Parser Bool
parseBool) Parser Bool -> Parser Bool -> Parser Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False)
  parseJSON _ = String -> Parser RefDate
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Could not parse RefDate"

{-
instance ToJSON RefDate where
  toJSON refdate = object' $ [
      "year" .= year refdate
    , "month" .= month refdate
    , "season" .= season refdate
    , "day" .= day refdate
    , "literal" .= other refdate ] ++
    [ "circa" .= circa refdate | circa refdate ]
-}

instance ToYaml RefDate where
  toYaml :: RefDate -> YamlBuilder
toYaml r :: RefDate
r = [[(Text, YamlBuilder)] -> [(Text, YamlBuilder)]] -> YamlBuilder
mapping'
               [ "year" Text -> Maybe Int -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Maybe Int
year RefDate
r
               , "month" Text -> Maybe Int -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Maybe Int
month RefDate
r
               , "season" Text
-> Maybe Season -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Maybe Season
season RefDate
r
               , "day" Text -> Maybe Int -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Maybe Int
day RefDate
r
               , "literal" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Literal
other RefDate
r
               , "circa" Text -> Bool -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= RefDate -> Bool
circa RefDate
r
               ]

instance OVERLAPS
         FromJSON [RefDate] where
  parseJSON :: Value -> Parser [RefDate]
parseJSON (Array xs :: Array
xs) = (Value -> Parser RefDate) -> [Value] -> Parser [RefDate]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Value -> Parser RefDate
forall a. FromJSON a => Value -> Parser a
parseJSON ([Value] -> Parser [RefDate]) -> [Value] -> Parser [RefDate]
forall a b. (a -> b) -> a -> b
$ Array -> [Value]
forall a. Vector a -> [a]
V.toList Array
xs
  parseJSON (Object v :: Object
v) = do
    Maybe String
raw' <- Object
v Object -> Text -> Parser (Maybe String)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "raw"
    Maybe Value
dateParts <- Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "date-parts"
    Bool
circa' <- (Object
v Object -> Text -> Parser Value
forall a. FromJSON a => Object -> Text -> Parser a
.: "circa" Parser Value -> (Value -> Parser Bool) -> Parser Bool
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Value -> Parser Bool
parseBool) Parser Bool -> Parser Bool -> Parser Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> Parser Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
    Maybe Season
season' <- Object
v Object -> Text -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "season" Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe Season)) -> Parser (Maybe Season)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Maybe Value -> Parser (Maybe Season)
parseMaybeSeason
    case Maybe Value
dateParts of
         Just (Array y :: Array
y) | Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
raw' ->
           case Array -> [Value]
forall a. Vector a -> [a]
V.toList Array
y of
              []           -> [RefDate] -> Parser [RefDate]
forall (m :: * -> *) a. Monad m => a -> m a
return []
              [Null]       -> [RefDate] -> Parser [RefDate]
forall (m :: * -> *) a. Monad m => a -> m a
return []
              [Array x :: Array
x]
                | Array -> Bool
forall a. Vector a -> Bool
V.null Array
x -> [RefDate] -> Parser [RefDate]
forall (m :: * -> *) a. Monad m => a -> m a
return []
                   -- [ null ] and [ [] ] are sometimes seen. See
                   -- https://github.com/greenelab/manubot/issues/66
              ys :: [Value]
ys           -> (Value -> Parser RefDate) -> [Value] -> Parser [RefDate]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((RefDate -> RefDate) -> Parser RefDate -> Parser RefDate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Bool -> RefDate -> RefDate
setCirca Bool
circa' (RefDate -> RefDate) -> (RefDate -> RefDate) -> RefDate -> RefDate
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                                (RefDate -> RefDate)
-> (Season -> RefDate -> RefDate)
-> Maybe Season
-> RefDate
-> RefDate
forall b a. b -> (a -> b) -> Maybe a -> b
maybe RefDate -> RefDate
forall a. a -> a
id Season -> RefDate -> RefDate
setSeason Maybe Season
season') (Parser RefDate -> Parser RefDate)
-> (Value -> Parser RefDate) -> Value -> Parser RefDate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser RefDate
forall a. FromJSON a => Value -> Parser a
parseJSON) [Value]
ys
         _ -> case Maybe String
raw' of
                  Nothing -> RefDate -> [RefDate]
handleLiteral (RefDate -> [RefDate]) -> Parser RefDate -> Parser [RefDate]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser RefDate
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
v)
                  Just r :: String
r  -> [RefDate] -> Parser [RefDate]
forall (m :: * -> *) a. Monad m => a -> m a
return ([RefDate] -> Parser [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a b. (a -> b) -> a -> b
$ String -> [RefDate]
parseRawDate String
r
  parseJSON x :: Value
x  = String -> [RefDate]
parseRawDate (String -> [RefDate]) -> Parser String -> Parser [RefDate]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser String
forall a. FromJSON a => Value -> Parser a
parseJSON Value
x

instance OVERLAPS
         ToJSON [RefDate] where
  toJSON :: [RefDate] -> Value
toJSON = [RefDate] -> Value
toJSONDate

toJSONDate :: [RefDate] -> Aeson.Value
toJSONDate :: [RefDate] -> Value
toJSONDate [] = Array -> Value
Array Array
forall a. Vector a
V.empty
toJSONDate ds :: [RefDate]
ds = [Pair] -> Value
object' ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
  [ "date-parts" Text -> [[Int]] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [[Int]]
dateparts | Bool -> Bool
not ([[Int]] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Int]]
dateparts) ] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
  ["circa" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (1 :: Int) | (RefDate -> Bool) -> [RefDate] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any RefDate -> Bool
circa [RefDate]
ds] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
  (case [Maybe Season] -> Maybe Season
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum ((RefDate -> Maybe Season) -> [RefDate] -> [Maybe Season]
forall a b. (a -> b) -> [a] -> [b]
map RefDate -> Maybe Season
season [RefDate]
ds) of
        Just (RawSeason s :: String
s) -> ["season" Text -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= String
s]
        _                  -> []) [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
  (case [Literal] -> Literal
forall a. Monoid a => [a] -> a
mconcat ((RefDate -> Literal) -> [RefDate] -> [Literal]
forall a b. (a -> b) -> [a] -> [b]
map RefDate -> Literal
other [RefDate]
ds) of
        Literal l :: String
l | Bool -> Bool
not (String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
l) -> ["literal" Text -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= String
l]
        _                        -> [])
  where dateparts :: [[Int]]
dateparts = ([Int] -> Bool) -> [[Int]] -> [[Int]]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ([Int] -> Bool) -> [Int] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Bool
forall a. (Eq a, Num a) => [a] -> Bool
emptyDatePart) ([[Int]] -> [[Int]]) -> [[Int]] -> [[Int]]
forall a b. (a -> b) -> a -> b
$ (RefDate -> [Int]) -> [RefDate] -> [[Int]]
forall a b. (a -> b) -> [a] -> [b]
map RefDate -> [Int]
toDatePart [RefDate]
ds
        emptyDatePart :: [a] -> Bool
emptyDatePart [] = Bool
True
        emptyDatePart xs :: [a]
xs = (a -> Bool) -> [a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== 0) [a]
xs

toDatePart :: RefDate -> [Int]
toDatePart :: RefDate -> [Int]
toDatePart refdate :: RefDate
refdate =
    case (RefDate -> Maybe Int
year RefDate
refdate, RefDate -> Maybe Int
month RefDate
refdate
           Maybe Int -> Maybe Int -> Maybe Int
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
          ((12Int -> Int -> Int
forall a. Num a => a -> a -> a
+) (Int -> Int) -> Maybe Int -> Maybe Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (RefDate -> Maybe Season
season RefDate
refdate Maybe Season -> (Season -> Maybe Int) -> Maybe Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Season -> Maybe Int
seasonToInt)),
          RefDate -> Maybe Int
day RefDate
refdate) of
         (Just (Int
y :: Int), Just (Int
m :: Int), Just (Int
d :: Int))
                                     -> [Int
y, Int
m, Int
d]
         (Just y :: Int
y, Just m :: Int
m, Nothing)   -> [Int
y, Int
m]
         (Just y :: Int
y, Nothing, Nothing)  -> [Int
y]
         _                           -> []


-- Zotero doesn't properly support date ranges, so a common
-- workaround is 2005_2007 or 2005_; support this as date range:
handleLiteral :: RefDate -> [RefDate]
handleLiteral :: RefDate -> [RefDate]
handleLiteral d :: RefDate
d@(RefDate Nothing Nothing Nothing Nothing (Literal xs :: String
xs) b :: Bool
b)
  = case (Char -> Bool) -> String -> [String]
forall a. (a -> Bool) -> [a] -> [[a]]
splitWhen (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
=='_') String
xs of
         [x :: String
x,y :: String
y] | (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isDigit String
x Bool -> Bool -> Bool
&& (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isDigit String
y Bool -> Bool -> Bool
&&
                 Bool -> Bool
not (String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
x) ->
                 [Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> Text -> Maybe Int
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
x) Maybe Int
forall a. Maybe a
Nothing Maybe Season
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Literal
forall a. Monoid a => a
mempty Bool
b,
                  Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate (Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> Text -> Maybe Int
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
y) Maybe Int
forall a. Maybe a
Nothing Maybe Season
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Literal
forall a. Monoid a => a
mempty Bool
b]
         _ -> [RefDate
d]
handleLiteral d :: RefDate
d = [RefDate
d]

setCirca :: Bool -> RefDate -> RefDate
setCirca :: Bool -> RefDate -> RefDate
setCirca circa' :: Bool
circa' rd :: RefDate
rd = RefDate
rd{ circa :: Bool
circa = Bool
circa' }

setSeason :: Season -> RefDate -> RefDate
setSeason :: Season -> RefDate -> RefDate
setSeason season' :: Season
season' rd :: RefDate
rd = RefDate
rd{ season :: Maybe Season
season = Season -> Maybe Season
forall a. a -> Maybe a
Just Season
season' }

data RefType
    = NoType
    | Article
    | ArticleMagazine
    | ArticleNewspaper
    | ArticleJournal
    | Bill
    | Book
    | Broadcast
    | Chapter
    | Dataset
    | Entry
    | EntryDictionary
    | EntryEncyclopedia
    | Figure
    | Graphic
    | Interview
    | Legislation
    | LegalCase
    | Manuscript
    | Map
    | MotionPicture
    | MusicalScore
    | Pamphlet
    | PaperConference
    | Patent
    | Post
    | PostWeblog
    | PersonalCommunication
    | Report
    | Review
    | ReviewBook
    | Song
    | Speech
    | Thesis
    | Treaty
    | Webpage
      deriving ( ReadPrec [RefType]
ReadPrec RefType
Int -> ReadS RefType
ReadS [RefType]
(Int -> ReadS RefType)
-> ReadS [RefType]
-> ReadPrec RefType
-> ReadPrec [RefType]
-> Read RefType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RefType]
$creadListPrec :: ReadPrec [RefType]
readPrec :: ReadPrec RefType
$creadPrec :: ReadPrec RefType
readList :: ReadS [RefType]
$creadList :: ReadS [RefType]
readsPrec :: Int -> ReadS RefType
$creadsPrec :: Int -> ReadS RefType
Read, RefType -> RefType -> Bool
(RefType -> RefType -> Bool)
-> (RefType -> RefType -> Bool) -> Eq RefType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RefType -> RefType -> Bool
$c/= :: RefType -> RefType -> Bool
== :: RefType -> RefType -> Bool
$c== :: RefType -> RefType -> Bool
Eq, Typeable, Typeable RefType
DataType
Constr
Typeable RefType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RefType -> c RefType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RefType)
-> (RefType -> Constr)
-> (RefType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RefType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefType))
-> ((forall b. Data b => b -> b) -> RefType -> RefType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RefType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RefType -> r)
-> (forall u. (forall d. Data d => d -> u) -> RefType -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RefType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RefType -> m RefType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RefType -> m RefType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RefType -> m RefType)
-> Data RefType
RefType -> DataType
RefType -> Constr
(forall b. Data b => b -> b) -> RefType -> RefType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefType -> c RefType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RefType -> u
forall u. (forall d. Data d => d -> u) -> RefType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RefType -> m RefType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefType -> m RefType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefType -> c RefType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RefType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefType)
$cWebpage :: Constr
$cTreaty :: Constr
$cThesis :: Constr
$cSpeech :: Constr
$cSong :: Constr
$cReviewBook :: Constr
$cReview :: Constr
$cReport :: Constr
$cPersonalCommunication :: Constr
$cPostWeblog :: Constr
$cPost :: Constr
$cPatent :: Constr
$cPaperConference :: Constr
$cPamphlet :: Constr
$cMusicalScore :: Constr
$cMotionPicture :: Constr
$cMap :: Constr
$cManuscript :: Constr
$cLegalCase :: Constr
$cLegislation :: Constr
$cInterview :: Constr
$cGraphic :: Constr
$cFigure :: Constr
$cEntryEncyclopedia :: Constr
$cEntryDictionary :: Constr
$cEntry :: Constr
$cDataset :: Constr
$cChapter :: Constr
$cBroadcast :: Constr
$cBook :: Constr
$cBill :: Constr
$cArticleJournal :: Constr
$cArticleNewspaper :: Constr
$cArticleMagazine :: Constr
$cArticle :: Constr
$cNoType :: Constr
$tRefType :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RefType -> m RefType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefType -> m RefType
gmapMp :: (forall d. Data d => d -> m d) -> RefType -> m RefType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RefType -> m RefType
gmapM :: (forall d. Data d => d -> m d) -> RefType -> m RefType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RefType -> m RefType
gmapQi :: Int -> (forall d. Data d => d -> u) -> RefType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RefType -> u
gmapQ :: (forall d. Data d => d -> u) -> RefType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RefType -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RefType -> r
gmapT :: (forall b. Data b => b -> b) -> RefType -> RefType
$cgmapT :: (forall b. Data b => b -> b) -> RefType -> RefType
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RefType)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RefType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RefType)
dataTypeOf :: RefType -> DataType
$cdataTypeOf :: RefType -> DataType
toConstr :: RefType -> Constr
$ctoConstr :: RefType -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RefType
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefType -> c RefType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RefType -> c RefType
$cp1Data :: Typeable RefType
Data, (forall x. RefType -> Rep RefType x)
-> (forall x. Rep RefType x -> RefType) -> Generic RefType
forall x. Rep RefType x -> RefType
forall x. RefType -> Rep RefType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RefType x -> RefType
$cfrom :: forall x. RefType -> Rep RefType x
Generic )

instance Show RefType where
    show :: RefType -> String
show x :: RefType
x = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower ShowS -> (RefType -> String) -> RefType -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
uncamelize ShowS -> (RefType -> String) -> RefType -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Constr -> String
showConstr (Constr -> String) -> (RefType -> Constr) -> RefType -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RefType -> Constr
forall a. Data a => a -> Constr
toConstr (RefType -> String) -> RefType -> String
forall a b. (a -> b) -> a -> b
$ RefType
x

instance FromJSON RefType where
  -- found in one of the test cases:
  parseJSON :: Value -> Parser RefType
parseJSON (String "film") = RefType -> Parser RefType
forall (m :: * -> *) a. Monad m => a -> m a
return RefType
MotionPicture
  parseJSON (String t :: Text
t) =
    Text -> Parser RefType
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (String -> Text
T.pack (String -> Text) -> (Text -> String) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
capitalize ShowS -> (Text -> String) -> Text -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
camelize ShowS -> (Text -> String) -> Text -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ Text
t) Parser RefType -> Parser RefType -> Parser RefType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    String -> Parser RefType
forall (m :: * -> *) a. MonadFail m => String -> m a
fail ("'" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
T.unpack Text
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ "' is not a valid reference type")
  parseJSON v :: Value
v@(Array _) =
    ([Inline] -> String) -> Parser [Inline] -> Parser String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ShowS
capitalize ShowS -> ([Inline] -> String) -> [Inline] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
camelize ShowS -> ([Inline] -> String) -> [Inline] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> String
inlinesToString) (Value -> Parser [Inline]
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v) Parser String -> (String -> Parser RefType) -> Parser RefType
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \t :: String
t ->
      Text -> Parser RefType
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (String -> Text
T.pack String
t) Parser RefType -> Parser RefType -> Parser RefType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
       String -> Parser RefType
forall (m :: * -> *) a. MonadFail m => String -> m a
fail ("'" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ "' is not a valid reference type")
  parseJSON _ = String -> Parser RefType
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Could not parse RefType"

instance ToJSON RefType where
  toJSON :: RefType -> Value
toJSON reftype :: RefType
reftype = String -> Value
forall a. ToJSON a => a -> Value
toJSON (ShowS
handleSpecialCases ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ RefType -> String
forall a. Show a => a -> String
show RefType
reftype)

instance ToYaml RefType where
  toYaml :: RefType -> YamlBuilder
toYaml r :: RefType
r = Text -> YamlBuilder
Y.string (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ ShowS
handleSpecialCases ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ RefType -> String
forall a. Show a => a -> String
show RefType
r)

-- For some reason, CSL is inconsistent about hyphens and underscores:
handleSpecialCases :: String -> String
handleSpecialCases :: ShowS
handleSpecialCases "motion-picture"         = "motion_picture"
handleSpecialCases "musical-score"          = "musical_score"
handleSpecialCases "personal-communication" = "personal_communication"
handleSpecialCases "legal-case"             = "legal_case"
handleSpecialCases x :: String
x                        = String
x

newtype CNum = CNum { CNum -> Int
unCNum :: Int }
  deriving ( Int -> CNum -> ShowS
[CNum] -> ShowS
CNum -> String
(Int -> CNum -> ShowS)
-> (CNum -> String) -> ([CNum] -> ShowS) -> Show CNum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CNum] -> ShowS
$cshowList :: [CNum] -> ShowS
show :: CNum -> String
$cshow :: CNum -> String
showsPrec :: Int -> CNum -> ShowS
$cshowsPrec :: Int -> CNum -> ShowS
Show, ReadPrec [CNum]
ReadPrec CNum
Int -> ReadS CNum
ReadS [CNum]
(Int -> ReadS CNum)
-> ReadS [CNum] -> ReadPrec CNum -> ReadPrec [CNum] -> Read CNum
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CNum]
$creadListPrec :: ReadPrec [CNum]
readPrec :: ReadPrec CNum
$creadPrec :: ReadPrec CNum
readList :: ReadS [CNum]
$creadList :: ReadS [CNum]
readsPrec :: Int -> ReadS CNum
$creadsPrec :: Int -> ReadS CNum
Read, CNum -> CNum -> Bool
(CNum -> CNum -> Bool) -> (CNum -> CNum -> Bool) -> Eq CNum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CNum -> CNum -> Bool
$c/= :: CNum -> CNum -> Bool
== :: CNum -> CNum -> Bool
$c== :: CNum -> CNum -> Bool
Eq, Eq CNum
Eq CNum =>
(CNum -> CNum -> Ordering)
-> (CNum -> CNum -> Bool)
-> (CNum -> CNum -> Bool)
-> (CNum -> CNum -> Bool)
-> (CNum -> CNum -> Bool)
-> (CNum -> CNum -> CNum)
-> (CNum -> CNum -> CNum)
-> Ord CNum
CNum -> CNum -> Bool
CNum -> CNum -> Ordering
CNum -> CNum -> CNum
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CNum -> CNum -> CNum
$cmin :: CNum -> CNum -> CNum
max :: CNum -> CNum -> CNum
$cmax :: CNum -> CNum -> CNum
>= :: CNum -> CNum -> Bool
$c>= :: CNum -> CNum -> Bool
> :: CNum -> CNum -> Bool
$c> :: CNum -> CNum -> Bool
<= :: CNum -> CNum -> Bool
$c<= :: CNum -> CNum -> Bool
< :: CNum -> CNum -> Bool
$c< :: CNum -> CNum -> Bool
compare :: CNum -> CNum -> Ordering
$ccompare :: CNum -> CNum -> Ordering
$cp1Ord :: Eq CNum
Ord, Integer -> CNum
CNum -> CNum
CNum -> CNum -> CNum
(CNum -> CNum -> CNum)
-> (CNum -> CNum -> CNum)
-> (CNum -> CNum -> CNum)
-> (CNum -> CNum)
-> (CNum -> CNum)
-> (CNum -> CNum)
-> (Integer -> CNum)
-> Num CNum
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> CNum
$cfromInteger :: Integer -> CNum
signum :: CNum -> CNum
$csignum :: CNum -> CNum
abs :: CNum -> CNum
$cabs :: CNum -> CNum
negate :: CNum -> CNum
$cnegate :: CNum -> CNum
* :: CNum -> CNum -> CNum
$c* :: CNum -> CNum -> CNum
- :: CNum -> CNum -> CNum
$c- :: CNum -> CNum -> CNum
+ :: CNum -> CNum -> CNum
$c+ :: CNum -> CNum -> CNum
Num, Typeable, Typeable CNum
DataType
Constr
Typeable CNum =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> CNum -> c CNum)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CNum)
-> (CNum -> Constr)
-> (CNum -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CNum))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CNum))
-> ((forall b. Data b => b -> b) -> CNum -> CNum)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r)
-> (forall u. (forall d. Data d => d -> u) -> CNum -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> CNum -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CNum -> m CNum)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CNum -> m CNum)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CNum -> m CNum)
-> Data CNum
CNum -> DataType
CNum -> Constr
(forall b. Data b => b -> b) -> CNum -> CNum
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CNum -> c CNum
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CNum
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CNum -> u
forall u. (forall d. Data d => d -> u) -> CNum -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CNum -> m CNum
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CNum -> m CNum
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CNum
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CNum -> c CNum
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CNum)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CNum)
$cCNum :: Constr
$tCNum :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CNum -> m CNum
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CNum -> m CNum
gmapMp :: (forall d. Data d => d -> m d) -> CNum -> m CNum
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CNum -> m CNum
gmapM :: (forall d. Data d => d -> m d) -> CNum -> m CNum
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CNum -> m CNum
gmapQi :: Int -> (forall d. Data d => d -> u) -> CNum -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CNum -> u
gmapQ :: (forall d. Data d => d -> u) -> CNum -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CNum -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CNum -> r
gmapT :: (forall b. Data b => b -> b) -> CNum -> CNum
$cgmapT :: (forall b. Data b => b -> b) -> CNum -> CNum
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CNum)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CNum)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CNum)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CNum)
dataTypeOf :: CNum -> DataType
$cdataTypeOf :: CNum -> DataType
toConstr :: CNum -> Constr
$ctoConstr :: CNum -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CNum
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CNum
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CNum -> c CNum
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CNum -> c CNum
$cp1Data :: Typeable CNum
Data, (forall x. CNum -> Rep CNum x)
-> (forall x. Rep CNum x -> CNum) -> Generic CNum
forall x. Rep CNum x -> CNum
forall x. CNum -> Rep CNum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CNum x -> CNum
$cfrom :: forall x. CNum -> Rep CNum x
Generic )

instance FromJSON CNum where
  parseJSON :: Value -> Parser CNum
parseJSON x :: Value
x = Int -> CNum
CNum (Int -> CNum) -> Parser Int -> Parser CNum
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Value -> Parser Int
parseInt Value
x

instance ToJSON CNum where
  toJSON :: CNum -> Value
toJSON (CNum n :: Int
n) = Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
n

instance ToYaml CNum where
  toYaml :: CNum -> YamlBuilder
toYaml r :: CNum
r = Text -> YamlBuilder
Y.string (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ CNum -> Int
unCNum CNum
r)

newtype CLabel = CLabel { CLabel -> String
unCLabel :: String } deriving ( Int -> CLabel -> ShowS
[CLabel] -> ShowS
CLabel -> String
(Int -> CLabel -> ShowS)
-> (CLabel -> String) -> ([CLabel] -> ShowS) -> Show CLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CLabel] -> ShowS
$cshowList :: [CLabel] -> ShowS
show :: CLabel -> String
$cshow :: CLabel -> String
showsPrec :: Int -> CLabel -> ShowS
$cshowsPrec :: Int -> CLabel -> ShowS
Show, ReadPrec [CLabel]
ReadPrec CLabel
Int -> ReadS CLabel
ReadS [CLabel]
(Int -> ReadS CLabel)
-> ReadS [CLabel]
-> ReadPrec CLabel
-> ReadPrec [CLabel]
-> Read CLabel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CLabel]
$creadListPrec :: ReadPrec [CLabel]
readPrec :: ReadPrec CLabel
$creadPrec :: ReadPrec CLabel
readList :: ReadS [CLabel]
$creadList :: ReadS [CLabel]
readsPrec :: Int -> ReadS CLabel
$creadsPrec :: Int -> ReadS CLabel
Read, CLabel -> CLabel -> Bool
(CLabel -> CLabel -> Bool)
-> (CLabel -> CLabel -> Bool) -> Eq CLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CLabel -> CLabel -> Bool
$c/= :: CLabel -> CLabel -> Bool
== :: CLabel -> CLabel -> Bool
$c== :: CLabel -> CLabel -> Bool
Eq, Typeable, Typeable CLabel
DataType
Constr
Typeable CLabel =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> CLabel -> c CLabel)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CLabel)
-> (CLabel -> Constr)
-> (CLabel -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CLabel))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CLabel))
-> ((forall b. Data b => b -> b) -> CLabel -> CLabel)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CLabel -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CLabel -> r)
-> (forall u. (forall d. Data d => d -> u) -> CLabel -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> CLabel -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CLabel -> m CLabel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CLabel -> m CLabel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CLabel -> m CLabel)
-> Data CLabel
CLabel -> DataType
CLabel -> Constr
(forall b. Data b => b -> b) -> CLabel -> CLabel
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CLabel -> c CLabel
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CLabel
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CLabel -> u
forall u. (forall d. Data d => d -> u) -> CLabel -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CLabel -> m CLabel
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CLabel -> m CLabel
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CLabel
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CLabel -> c CLabel
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CLabel)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CLabel)
$cCLabel :: Constr
$tCLabel :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CLabel -> m CLabel
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CLabel -> m CLabel
gmapMp :: (forall d. Data d => d -> m d) -> CLabel -> m CLabel
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CLabel -> m CLabel
gmapM :: (forall d. Data d => d -> m d) -> CLabel -> m CLabel
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CLabel -> m CLabel
gmapQi :: Int -> (forall d. Data d => d -> u) -> CLabel -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CLabel -> u
gmapQ :: (forall d. Data d => d -> u) -> CLabel -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CLabel -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CLabel -> r
gmapT :: (forall b. Data b => b -> b) -> CLabel -> CLabel
$cgmapT :: (forall b. Data b => b -> b) -> CLabel -> CLabel
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CLabel)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CLabel)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CLabel)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CLabel)
dataTypeOf :: CLabel -> DataType
$cdataTypeOf :: CLabel -> DataType
toConstr :: CLabel -> Constr
$ctoConstr :: CLabel -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CLabel
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CLabel
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CLabel -> c CLabel
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CLabel -> c CLabel
$cp1Data :: Typeable CLabel
Data, (forall x. CLabel -> Rep CLabel x)
-> (forall x. Rep CLabel x -> CLabel) -> Generic CLabel
forall x. Rep CLabel x -> CLabel
forall x. CLabel -> Rep CLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CLabel x -> CLabel
$cfrom :: forall x. CLabel -> Rep CLabel x
Generic, b -> CLabel -> CLabel
NonEmpty CLabel -> CLabel
CLabel -> CLabel -> CLabel
(CLabel -> CLabel -> CLabel)
-> (NonEmpty CLabel -> CLabel)
-> (forall b. Integral b => b -> CLabel -> CLabel)
-> Semigroup CLabel
forall b. Integral b => b -> CLabel -> CLabel
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> CLabel -> CLabel
$cstimes :: forall b. Integral b => b -> CLabel -> CLabel
sconcat :: NonEmpty CLabel -> CLabel
$csconcat :: NonEmpty CLabel -> CLabel
<> :: CLabel -> CLabel -> CLabel
$c<> :: CLabel -> CLabel -> CLabel
Semigroup, Semigroup CLabel
CLabel
Semigroup CLabel =>
CLabel
-> (CLabel -> CLabel -> CLabel)
-> ([CLabel] -> CLabel)
-> Monoid CLabel
[CLabel] -> CLabel
CLabel -> CLabel -> CLabel
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [CLabel] -> CLabel
$cmconcat :: [CLabel] -> CLabel
mappend :: CLabel -> CLabel -> CLabel
$cmappend :: CLabel -> CLabel -> CLabel
mempty :: CLabel
$cmempty :: CLabel
$cp1Monoid :: Semigroup CLabel
Monoid )

instance FromJSON CLabel where
  parseJSON :: Value -> Parser CLabel
parseJSON x :: Value
x = String -> CLabel
CLabel (String -> CLabel) -> Parser String -> Parser CLabel
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Value -> Parser String
parseString Value
x

instance ToJSON CLabel where
  toJSON :: CLabel -> Value
toJSON (CLabel s :: String
s) = String -> Value
forall a. ToJSON a => a -> Value
toJSON String
s

instance ToYaml CLabel where
  toYaml :: CLabel -> YamlBuilder
toYaml (CLabel s :: String
s) = Text -> YamlBuilder
forall a. ToYaml a => a -> YamlBuilder
toYaml (Text -> YamlBuilder) -> Text -> YamlBuilder
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
s

-- | The 'Reference' record.
data Reference =
    Reference
    { Reference -> Literal
refId                    :: Literal
    , Reference -> [Literal]
refOtherIds              :: [Literal]
    , Reference -> RefType
refType                  :: RefType

    , Reference -> [Agent]
author                   :: [Agent]
    , Reference -> [Agent]
editor                   :: [Agent]
    , Reference -> [Agent]
translator               :: [Agent]
    , Reference -> [Agent]
recipient                :: [Agent]
    , Reference -> [Agent]
interviewer              :: [Agent]
    , Reference -> [Agent]
composer                 :: [Agent]
    , Reference -> [Agent]
director                 :: [Agent]
    , Reference -> [Agent]
illustrator              :: [Agent]
    , Reference -> [Agent]
originalAuthor           :: [Agent]
    , Reference -> [Agent]
containerAuthor          :: [Agent]
    , Reference -> [Agent]
collectionEditor         :: [Agent]
    , Reference -> [Agent]
editorialDirector        :: [Agent]
    , Reference -> [Agent]
reviewedAuthor           :: [Agent]

    , Reference -> [RefDate]
issued                   :: [RefDate]
    , Reference -> [RefDate]
eventDate                :: [RefDate]
    , Reference -> [RefDate]
accessed                 :: [RefDate]
    , Reference -> [RefDate]
container                :: [RefDate]
    , Reference -> [RefDate]
originalDate             :: [RefDate]
    , Reference -> [RefDate]
submitted                :: [RefDate]

    , Reference -> Formatted
title                    :: Formatted
    , Reference -> Formatted
titleShort               :: Formatted
    , Reference -> Formatted
reviewedTitle            :: Formatted
    , Reference -> Formatted
containerTitle           :: Formatted
    , Reference -> Formatted
volumeTitle              :: Formatted
    , Reference -> Formatted
collectionTitle          :: Formatted
    , Reference -> Formatted
containerTitleShort      :: Formatted
    , Reference -> Formatted
collectionNumber         :: Formatted --Int
    , Reference -> Formatted
originalTitle            :: Formatted
    , Reference -> Formatted
publisher                :: Formatted
    , Reference -> Formatted
originalPublisher        :: Formatted
    , Reference -> Formatted
publisherPlace           :: Formatted
    , Reference -> Formatted
originalPublisherPlace   :: Formatted
    , Reference -> Formatted
authority                :: Formatted
    , Reference -> Formatted
jurisdiction             :: Formatted
    , Reference -> Formatted
archive                  :: Formatted
    , Reference -> Formatted
archivePlace             :: Formatted
    , Reference -> Formatted
archiveLocation          :: Formatted
    , Reference -> Formatted
event                    :: Formatted
    , Reference -> Formatted
eventPlace               :: Formatted
    , Reference -> Formatted
page                     :: Formatted
    , Reference -> Formatted
pageFirst                :: Formatted
    , Reference -> Formatted
numberOfPages            :: Formatted
    , Reference -> Formatted
version                  :: Formatted
    , Reference -> Formatted
volume                   :: Formatted
    , Reference -> Formatted
numberOfVolumes          :: Formatted --Int
    , Reference -> Formatted
issue                    :: Formatted
    , Reference -> Formatted
chapterNumber            :: Formatted
    , Reference -> Formatted
medium                   :: Formatted
    , Reference -> Formatted
status                   :: Formatted
    , Reference -> Formatted
edition                  :: Formatted
    , Reference -> Formatted
section                  :: Formatted
    , Reference -> Formatted
source                   :: Formatted
    , Reference -> Formatted
genre                    :: Formatted
    , Reference -> Formatted
note                     :: Formatted
    , Reference -> Formatted
annote                   :: Formatted
    , Reference -> Formatted
abstract                 :: Formatted
    , Reference -> Formatted
keyword                  :: Formatted
    , Reference -> Formatted
number                   :: Formatted
    , Reference -> Formatted
references               :: Formatted
    , Reference -> Literal
url                      :: Literal
    , Reference -> Literal
doi                      :: Literal
    , Reference -> Literal
isbn                     :: Literal
    , Reference -> Literal
issn                     :: Literal
    , Reference -> Literal
pmcid                    :: Literal
    , Reference -> Literal
pmid                     :: Literal
    , Reference -> Literal
callNumber               :: Literal
    , Reference -> Literal
dimensions               :: Literal
    , Reference -> Literal
scale                    :: Literal
    , Reference -> [Literal]
categories               :: [Literal]
    , Reference -> Literal
language                 :: Literal

    , Reference -> CNum
citationNumber           :: CNum
    , Reference -> Int
firstReferenceNoteNumber :: Int
    , Reference -> CLabel
citationLabel            :: CLabel
    } deriving ( Reference -> Reference -> Bool
(Reference -> Reference -> Bool)
-> (Reference -> Reference -> Bool) -> Eq Reference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reference -> Reference -> Bool
$c/= :: Reference -> Reference -> Bool
== :: Reference -> Reference -> Bool
$c== :: Reference -> Reference -> Bool
Eq, Int -> Reference -> ShowS
[Reference] -> ShowS
Reference -> String
(Int -> Reference -> ShowS)
-> (Reference -> String)
-> ([Reference] -> ShowS)
-> Show Reference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reference] -> ShowS
$cshowList :: [Reference] -> ShowS
show :: Reference -> String
$cshow :: Reference -> String
showsPrec :: Int -> Reference -> ShowS
$cshowsPrec :: Int -> Reference -> ShowS
Show, ReadPrec [Reference]
ReadPrec Reference
Int -> ReadS Reference
ReadS [Reference]
(Int -> ReadS Reference)
-> ReadS [Reference]
-> ReadPrec Reference
-> ReadPrec [Reference]
-> Read Reference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Reference]
$creadListPrec :: ReadPrec [Reference]
readPrec :: ReadPrec Reference
$creadPrec :: ReadPrec Reference
readList :: ReadS [Reference]
$creadList :: ReadS [Reference]
readsPrec :: Int -> ReadS Reference
$creadsPrec :: Int -> ReadS Reference
Read, Typeable, Typeable Reference
DataType
Constr
Typeable Reference =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Reference -> c Reference)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Reference)
-> (Reference -> Constr)
-> (Reference -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Reference))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Reference))
-> ((forall b. Data b => b -> b) -> Reference -> Reference)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Reference -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Reference -> r)
-> (forall u. (forall d. Data d => d -> u) -> Reference -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Reference -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Reference -> m Reference)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Reference -> m Reference)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Reference -> m Reference)
-> Data Reference
Reference -> DataType
Reference -> Constr
(forall b. Data b => b -> b) -> Reference -> Reference
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Reference -> c Reference
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Reference
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Reference -> u
forall u. (forall d. Data d => d -> u) -> Reference -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Reference -> m Reference
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Reference -> m Reference
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Reference
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Reference -> c Reference
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Reference)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Reference)
$cReference :: Constr
$tReference :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Reference -> m Reference
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Reference -> m Reference
gmapMp :: (forall d. Data d => d -> m d) -> Reference -> m Reference
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Reference -> m Reference
gmapM :: (forall d. Data d => d -> m d) -> Reference -> m Reference
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Reference -> m Reference
gmapQi :: Int -> (forall d. Data d => d -> u) -> Reference -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Reference -> u
gmapQ :: (forall d. Data d => d -> u) -> Reference -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Reference -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Reference -> r
gmapT :: (forall b. Data b => b -> b) -> Reference -> Reference
$cgmapT :: (forall b. Data b => b -> b) -> Reference -> Reference
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Reference)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Reference)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Reference)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Reference)
dataTypeOf :: Reference -> DataType
$cdataTypeOf :: Reference -> DataType
toConstr :: Reference -> Constr
$ctoConstr :: Reference -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Reference
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Reference
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Reference -> c Reference
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Reference -> c Reference
$cp1Data :: Typeable Reference
Data, (forall x. Reference -> Rep Reference x)
-> (forall x. Rep Reference x -> Reference) -> Generic Reference
forall x. Rep Reference x -> Reference
forall x. Reference -> Rep Reference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Reference x -> Reference
$cfrom :: forall x. Reference -> Rep Reference x
Generic )

instance FromJSON Reference where
  parseJSON :: Value -> Parser Reference
parseJSON (Object v' :: Object
v') = do
     Object
v <- Object -> Parser Object
parseSuppFields Object
v' Parser Object -> Parser Object -> Parser Object
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Object -> Parser Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
v'
     (Literal
-> [Literal]
-> RefType
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> [Literal]
-> Literal
-> CNum
-> Int
-> CLabel
-> Reference
Reference (Literal
 -> [Literal]
 -> RefType
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [Agent]
 -> [RefDate]
 -> [RefDate]
 -> [RefDate]
 -> [RefDate]
 -> [RefDate]
 -> [RefDate]
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Formatted
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> Literal
 -> [Literal]
 -> Literal
 -> CNum
 -> Int
 -> CLabel
 -> Reference)
-> Parser Literal
-> Parser
     ([Literal]
      -> RefType
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "id" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  ([Literal]
   -> RefType
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Literal]
-> Parser
     (RefType
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Literal])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "other-ids" Parser (Maybe [Literal]) -> [Literal] -> Parser [Literal]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  (RefType
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser RefType
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe RefType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "type" Parser (Maybe RefType) -> RefType -> Parser RefType
forall a. Parser (Maybe a) -> a -> Parser a
.!= RefType
NoType Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "author" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "editor" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "translator" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "recipient" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "interviewer" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "composer" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "director" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "illustrator" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "original-author" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "container-author" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "collection-editor" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([Agent]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "editorial-director" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([Agent]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [Agent]
-> Parser
     ([RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Agent])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "reviewed-author" Parser (Maybe [Agent]) -> [Agent] -> Parser [Agent]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     ([RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "issued" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     ([RefDate]
      -> [RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "event-date" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> [RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     ([RefDate]
      -> [RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "accessed" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> [RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     ([RefDate]
      -> [RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "container" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> [RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     ([RefDate]
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "original-date" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  ([RefDate]
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser [RefDate]
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [RefDate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "submitted" Parser (Maybe [RefDate]) -> [RefDate] -> Parser [RefDate]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       (Object
v Object -> Text -> Parser Formatted
forall a. FromJSON a => Object -> Text -> Parser a
.: "shortTitle" Parser Formatted -> Parser Formatted -> Parser Formatted
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "title-short" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty)) Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "reviewed-title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "container-title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "volume-title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "collection-title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       (Object
v Object -> Text -> Parser Formatted
forall a. FromJSON a => Object -> Text -> Parser a
.: "journalAbbreviation" Parser Formatted -> Parser Formatted -> Parser Formatted
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "container-title-short" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty) Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "collection-number" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "original-title" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "publisher" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "original-publisher" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "publisher-place" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "original-publisher-place" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "authority" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "jurisdiction" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "archive" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "archive-place" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "archive_location" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "event" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "event-place" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "page" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "page-first" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "number-of-pages" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "version" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "volume" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "number-of-volumes" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "issue" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "chapter-number" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "medium" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "status" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "edition" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "section" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "source" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "genre" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "note" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "annote" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "abstract" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "keyword" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Formatted
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "number" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Formatted
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Formatted
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Formatted)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "references" Parser (Maybe Formatted) -> Formatted -> Parser Formatted
forall a. Parser (Maybe a) -> a -> Parser a
.!= Formatted
forall a. Monoid a => a
mempty Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "URL" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "DOI" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "ISBN" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "ISSN" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "PMCID" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "PMID" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> Literal
      -> [Literal]
      -> Literal
      -> CNum
      -> Int
      -> CLabel
      -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "call-number" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> Literal
   -> [Literal]
   -> Literal
   -> CNum
   -> Int
   -> CLabel
   -> Reference)
-> Parser Literal
-> Parser
     (Literal
      -> [Literal] -> Literal -> CNum -> Int -> CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "dimensions" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser
  (Literal
   -> [Literal] -> Literal -> CNum -> Int -> CLabel -> Reference)
-> Parser Literal
-> Parser
     ([Literal] -> Literal -> CNum -> Int -> CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "scale" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser ([Literal] -> Literal -> CNum -> Int -> CLabel -> Reference)
-> Parser [Literal]
-> Parser (Literal -> CNum -> Int -> CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe [Literal])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "categories" Parser (Maybe [Literal]) -> [Literal] -> Parser [Literal]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [] Parser (Literal -> CNum -> Int -> CLabel -> Reference)
-> Parser Literal -> Parser (CNum -> Int -> CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe Literal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "language" Parser (Maybe Literal) -> Literal -> Parser Literal
forall a. Parser (Maybe a) -> a -> Parser a
.!= "" Parser (CNum -> Int -> CLabel -> Reference)
-> Parser CNum -> Parser (Int -> CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe CNum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "citation-number" Parser (Maybe CNum) -> CNum -> Parser CNum
forall a. Parser (Maybe a) -> a -> Parser a
.!= Int -> CNum
CNum 0 Parser (Int -> CLabel -> Reference)
-> Parser Int -> Parser (CLabel -> Reference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       ((Object
v Object -> Text -> Parser Value
forall a. FromJSON a => Object -> Text -> Parser a
.: "first-reference-note-number" Parser Value -> (Value -> Parser Int) -> Parser Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Value -> Parser Int
parseInt) Parser Int -> Parser Int -> Parser Int
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Int -> Parser Int
forall (m :: * -> *) a. Monad m => a -> m a
return 0) Parser (CLabel -> Reference) -> Parser CLabel -> Parser Reference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
       Object
v Object -> Text -> Parser (Maybe CLabel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? "citation-label" Parser (Maybe CLabel) -> CLabel -> Parser CLabel
forall a. Parser (Maybe a) -> a -> Parser a
.!= CLabel
forall a. Monoid a => a
mempty)
  parseJSON _ = String -> Parser Reference
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Could not parse Reference"

-- Syntax for adding supplementary fields in note variable
-- {:authority:Superior Court of California}{:section:A}{:original-date:1777}
-- or
-- Foo\nissued: 2016-03-20/2016-07-31\nbar
-- see http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#supplementary-fields
parseSuppFields :: Aeson.Object -> Parser Aeson.Object
parseSuppFields :: Object -> Parser Object
parseSuppFields o :: Object
o = do
  String
nt <- Object
o Object -> Text -> Parser String
forall a. FromJSON a => Object -> Text -> Parser a
.: "note"
  case Parsec String () [Pair]
-> String -> String -> Either ParseError [Pair]
forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
P.parse Parsec String () [Pair]
noteFields "note" String
nt of
       Left err :: ParseError
err -> String -> Parser Object
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (ParseError -> String
forall a. Show a => a -> String
show ParseError
err)
       Right fs :: [Pair]
fs -> Object -> Parser Object
forall (m :: * -> *) a. Monad m => a -> m a
return (Object -> Parser Object) -> Object -> Parser Object
forall a b. (a -> b) -> a -> b
$ (Pair -> Object -> Object) -> Object -> [Pair] -> Object
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(k :: Text
k,v :: Value
v) x :: Object
x -> Text -> Value -> Object -> Object
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
H.insert Text
k Value
v Object
x) Object
o [Pair]
fs

noteFields :: P.Parser [(Text, Aeson.Value)]
noteFields :: Parsec String () [Pair]
noteFields = do
  [Either Text Pair]
fs <- ParsecT String () Identity (Either Text Pair)
-> ParsecT String () Identity [Either Text Pair]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
P.many (Pair -> Either Text Pair
forall a b. b -> Either a b
Right (Pair -> Either Text Pair)
-> ParsecT String () Identity Pair
-> ParsecT String () Identity (Either Text Pair)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT String () Identity Pair
noteField ParsecT String () Identity Pair
-> ParsecT String () Identity Pair
-> ParsecT String () Identity Pair
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT String () Identity Pair
lineNoteField) ParsecT String () Identity (Either Text Pair)
-> ParsecT String () Identity (Either Text Pair)
-> ParsecT String () Identity (Either Text Pair)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Either Text Pair
forall a b. a -> Either a b
Left (Text -> Either Text Pair)
-> ParsecT String () Identity Text
-> ParsecT String () Identity (Either Text Pair)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Text
regText)
  ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
P.spaces
  let rest :: Text
rest = [Text] -> Text
T.unwords ([Either Text Pair] -> [Text]
forall a b. [Either a b] -> [a]
lefts [Either Text Pair]
fs)
  [Pair] -> Parsec String () [Pair]
forall (m :: * -> *) a. Monad m => a -> m a
return (("note", Text -> Value
Aeson.String Text
rest) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Either Text Pair] -> [Pair]
forall a b. [Either a b] -> [b]
rights [Either Text Pair]
fs)

noteField :: P.Parser (Text, Aeson.Value)
noteField :: ParsecT String () Identity Pair
noteField = ParsecT String () Identity Pair -> ParsecT String () Identity Pair
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String () Identity Pair
 -> ParsecT String () Identity Pair)
-> ParsecT String () Identity Pair
-> ParsecT String () Identity Pair
forall a b. (a -> b) -> a -> b
$ do
  Char
_ <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '{'
  Char
_ <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ':'
  String
k <- ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
P.manyTill (ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.letter ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '-') (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ':')
  ()
_ <- ParsecT String () Identity Char -> ParsecT String () Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
P.skipMany (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ' ')
  String
v <- ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
P.manyTill ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.anyChar (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '}')
  Pair -> ParsecT String () Identity Pair
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Text
T.pack String
k, Text -> Value
Aeson.String (String -> Text
T.pack String
v))

lineNoteField :: P.Parser (Text, Aeson.Value)
lineNoteField :: ParsecT String () Identity Pair
lineNoteField = ParsecT String () Identity Pair -> ParsecT String () Identity Pair
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String () Identity Pair
 -> ParsecT String () Identity Pair)
-> ParsecT String () Identity Pair
-> ParsecT String () Identity Pair
forall a b. (a -> b) -> a -> b
$ do
  Char
_ <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '\n'
  String
k <- ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
P.manyTill (ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.letter ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '-') (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ':')
  ()
_ <- ParsecT String () Identity Char -> ParsecT String () Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
P.skipMany (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ' ')
  String
v <- ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
P.manyTill ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.anyChar (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '\n' ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> '\n' Char
-> ParsecT String () Identity () -> ParsecT String () Identity Char
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT String () Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
P.eof)
  Pair -> ParsecT String () Identity Pair
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Text
T.pack String
k, Text -> Value
Aeson.String (String -> Text
T.pack String
v))

regText :: P.Parser Text
regText :: ParsecT String () Identity Text
regText = (String -> Text
T.pack (String -> Text)
-> ParsecT String () Identity String
-> ParsecT String () Identity Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 (String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
P.noneOf "\n{")) ParsecT String () Identity Text
-> ParsecT String () Identity Text
-> ParsecT String () Identity Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Char -> Text
T.singleton (Char -> Text)
-> ParsecT String () Identity Char
-> ParsecT String () Identity Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.anyChar)

instance ToJSON Reference where
  toJSON :: Reference -> Value
toJSON ref :: Reference
ref = [Pair] -> Value
object' [
      "id" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
refId Reference
ref
    , "other-ids" Text -> [Literal] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Literal]
refOtherIds Reference
ref
    , "type" Text -> RefType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> RefType
refType Reference
ref
    , "author" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
author Reference
ref
    , "editor" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
editor Reference
ref
    , "translator" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
translator Reference
ref
    , "recipient" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
recipient Reference
ref
    , "interviewer" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
interviewer Reference
ref
    , "composer" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
composer Reference
ref
    , "director" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
director Reference
ref
    , "illustrator" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
illustrator Reference
ref
    , "original-author" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
originalAuthor Reference
ref
    , "container-author" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
containerAuthor Reference
ref
    , "collection-editor" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
collectionEditor Reference
ref
    , "editorial-director" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
editorialDirector Reference
ref
    , "reviewed-author" Text -> [Agent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Agent]
reviewedAuthor Reference
ref
    , "issued" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
issued Reference
ref
    , "event-date" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
eventDate Reference
ref
    , "accessed" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
accessed Reference
ref
    , "container" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
container Reference
ref
    , "original-date" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
originalDate Reference
ref
    , "submitted" Text -> [RefDate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [RefDate]
submitted Reference
ref
    , "title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
title Reference
ref
    , "title-short" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
titleShort Reference
ref
    , "reviewed-title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
reviewedTitle Reference
ref
    , "container-title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
containerTitle Reference
ref
    , "volume-title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
volumeTitle Reference
ref
    , "collection-title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
collectionTitle Reference
ref
    , "container-title-short" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
containerTitleShort Reference
ref
    , "collection-number" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
collectionNumber Reference
ref
    , "original-title" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
originalTitle Reference
ref
    , "publisher" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
publisher Reference
ref
    , "original-publisher" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
originalPublisher Reference
ref
    , "publisher-place" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
publisherPlace Reference
ref
    , "original-publisher-place" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
originalPublisherPlace Reference
ref
    , "authority" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
authority Reference
ref
    , "jurisdiction" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
jurisdiction Reference
ref
    , "archive" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
archive Reference
ref
    , "archive-place" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
archivePlace Reference
ref
    , "archive_location" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
archiveLocation Reference
ref
    , "event" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
event Reference
ref
    , "event-place" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
eventPlace Reference
ref
    , "page" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
page Reference
ref
    , "page-first" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (if Reference -> Formatted
page Reference
ref Formatted -> Formatted -> Bool
forall a. Eq a => a -> a -> Bool
== Formatted
forall a. Monoid a => a
mempty then Reference -> Formatted
pageFirst Reference
ref else Formatted
forall a. Monoid a => a
mempty)
    , "number-of-pages" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
numberOfPages Reference
ref
    , "version" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
version Reference
ref
    , "volume" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
volume Reference
ref
    , "number-of-volumes" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
numberOfVolumes Reference
ref
    , "issue" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
issue Reference
ref
    , "chapter-number" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
chapterNumber Reference
ref
    , "medium" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
medium Reference
ref
    , "status" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
status Reference
ref
    , "edition" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
edition Reference
ref
    , "section" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
section Reference
ref
    , "source" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
source Reference
ref
    , "genre" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
genre Reference
ref
    , "note" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
note Reference
ref
    , "annote" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
annote Reference
ref
    , "abstract" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
abstract Reference
ref
    , "keyword" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
keyword Reference
ref
    , "number" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
number Reference
ref
    , "references" Text -> Formatted -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Formatted
references Reference
ref
    , "URL" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
url Reference
ref
    , "DOI" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
doi Reference
ref
    , "ISBN" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
isbn Reference
ref
    , "ISSN" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
issn Reference
ref
    , "PMCID" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
pmcid Reference
ref
    , "PMID" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
pmid Reference
ref
    , "call-number" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
callNumber Reference
ref
    , "dimensions" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
dimensions Reference
ref
    , "scale" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
scale Reference
ref
    , "categories" Text -> [Literal] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> [Literal]
categories Reference
ref
    , "language" Text -> Literal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Literal
language Reference
ref
    , "citation-number" Text -> CNum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> CNum
citationNumber Reference
ref
    , "first-reference-note-number" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> Int
firstReferenceNoteNumber Reference
ref
    , "citation-label" Text -> CLabel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reference -> CLabel
citationLabel Reference
ref
    ]

instance ToYaml Reference where
  toYaml :: Reference -> YamlBuilder
toYaml ref :: Reference
ref = [[(Text, YamlBuilder)] -> [(Text, YamlBuilder)]] -> YamlBuilder
mapping' [
      "id" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
refId Reference
ref
    , "other-ids" Text -> [Literal] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Literal]
refOtherIds Reference
ref
    , (("type" Text -> RefType -> (Text, YamlBuilder)
forall a. ToYaml a => Text -> a -> (Text, YamlBuilder)
Y..= Reference -> RefType
refType Reference
ref) (Text, YamlBuilder)
-> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> [a] -> [a]
:)
    , "author" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
author Reference
ref
    , "editor" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
editor Reference
ref
    , "translator" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
translator Reference
ref
    , "recipient" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
recipient Reference
ref
    , "interviewer" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
interviewer Reference
ref
    , "composer" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
composer Reference
ref
    , "director" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
director Reference
ref
    , "illustrator" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
illustrator Reference
ref
    , "original-author" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
originalAuthor Reference
ref
    , "container-author" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
containerAuthor Reference
ref
    , "collection-editor" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
collectionEditor Reference
ref
    , "editorial-director" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
editorialDirector Reference
ref
    , "reviewed-author" Text -> [Agent] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Agent]
reviewedAuthor Reference
ref
    , "issued" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
issued Reference
ref
    , "event-date" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
eventDate Reference
ref
    , "accessed" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
accessed Reference
ref
    , "container" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
container Reference
ref
    , "original-date" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
originalDate Reference
ref
    , "submitted" Text -> [RefDate] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [RefDate]
submitted Reference
ref
    , "title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
title Reference
ref
    , "title-short" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
titleShort Reference
ref
    , "reviewed-title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
reviewedTitle Reference
ref
    , "container-title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
containerTitle Reference
ref
    , "volume-title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
volumeTitle Reference
ref
    , "collection-title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
collectionTitle Reference
ref
    , "container-title-short" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
containerTitleShort Reference
ref
    , "collection-number" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
collectionNumber Reference
ref
    , "original-title" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
originalTitle Reference
ref
    , "publisher" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
publisher Reference
ref
    , "original-publisher" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
originalPublisher Reference
ref
    , "publisher-place" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
publisherPlace Reference
ref
    , "original-publisher-place" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
originalPublisherPlace Reference
ref
    , "authority" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
authority Reference
ref
    , "jurisdiction" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
jurisdiction Reference
ref
    , "archive" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
archive Reference
ref
    , "archive-place" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
archivePlace Reference
ref
    , "archive_location" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
archiveLocation Reference
ref
    , "event" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
event Reference
ref
    , "event-place" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
eventPlace Reference
ref
    , "page" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
page Reference
ref
    , "page-first" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= (if Reference -> Formatted
page Reference
ref Formatted -> Formatted -> Bool
forall a. Eq a => a -> a -> Bool
== Formatted
forall a. Monoid a => a
mempty then Reference -> Formatted
pageFirst Reference
ref else Formatted
forall a. Monoid a => a
mempty)
    , "number-of-pages" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
numberOfPages Reference
ref
    , "version" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
version Reference
ref
    , "volume" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
volume Reference
ref
    , "number-of-volumes" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
numberOfVolumes Reference
ref
    , "issue" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
issue Reference
ref
    , "chapter-number" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
chapterNumber Reference
ref
    , "medium" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
medium Reference
ref
    , "status" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
status Reference
ref
    , "edition" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
edition Reference
ref
    , "section" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
section Reference
ref
    , "source" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
source Reference
ref
    , "genre" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
genre Reference
ref
    , "note" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
note Reference
ref
    , "annote" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
annote Reference
ref
    , "abstract" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
abstract Reference
ref
    , "keyword" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
keyword Reference
ref
    , "number" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
number Reference
ref
    , "references" Text -> Formatted -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Formatted
references Reference
ref
    , "URL" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
url Reference
ref
    , "DOI" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
doi Reference
ref
    , "ISBN" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
isbn Reference
ref
    , "ISSN" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
issn Reference
ref
    , "PMCID" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
pmcid Reference
ref
    , "PMID" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
pmid Reference
ref
    , "call-number" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
callNumber Reference
ref
    , "dimensions" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
dimensions Reference
ref
    , "scale" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
scale Reference
ref
    , "categories" Text -> [Literal] -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> [Literal]
categories Reference
ref
    , "language" Text -> Literal -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a.
AddYaml a =>
Text -> a -> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
&= Reference -> Literal
language Reference
ref
    , if Reference -> CNum
citationNumber Reference
ref CNum -> CNum -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> CNum
CNum 0
         then [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> a
id
         else (("citation-number" Text -> CNum -> (Text, YamlBuilder)
forall a. ToYaml a => Text -> a -> (Text, YamlBuilder)
Y..= Reference -> CNum
citationNumber Reference
ref) (Text, YamlBuilder)
-> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> [a] -> [a]
:)
    , if Reference -> Int
firstReferenceNoteNumber Reference
ref Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 0
         then [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> a
id
         else (("first-reference-note-number" Text -> Int -> (Text, YamlBuilder)
forall a. ToYaml a => Text -> a -> (Text, YamlBuilder)
Y..=
                Reference -> Int
firstReferenceNoteNumber Reference
ref) (Text, YamlBuilder)
-> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> [a] -> [a]
:)
    , if Reference -> CLabel
citationLabel Reference
ref CLabel -> CLabel -> Bool
forall a. Eq a => a -> a -> Bool
== CLabel
forall a. Monoid a => a
mempty
         then [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> a
id
         else (("citation-label" Text -> CLabel -> (Text, YamlBuilder)
forall a. ToYaml a => Text -> a -> (Text, YamlBuilder)
Y..= Reference -> CLabel
citationLabel Reference
ref) (Text, YamlBuilder)
-> [(Text, YamlBuilder)] -> [(Text, YamlBuilder)]
forall a. a -> [a] -> [a]
:)
    ]

emptyReference :: Reference
emptyReference :: Reference
emptyReference =
    Reference :: Literal
-> [Literal]
-> RefType
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [Agent]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> [RefDate]
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Formatted
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> Literal
-> [Literal]
-> Literal
-> CNum
-> Int
-> CLabel
-> Reference
Reference
    { refId :: Literal
refId               = Literal
forall a. Monoid a => a
mempty
    , refOtherIds :: [Literal]
refOtherIds         = [Literal]
forall a. Monoid a => a
mempty
    , refType :: RefType
refType             = RefType
NoType

    , author :: [Agent]
author              = []
    , editor :: [Agent]
editor              = []
    , translator :: [Agent]
translator          = []
    , recipient :: [Agent]
recipient           = []
    , interviewer :: [Agent]
interviewer         = []
    , composer :: [Agent]
composer            = []
    , director :: [Agent]
director            = []
    , illustrator :: [Agent]
illustrator         = []
    , originalAuthor :: [Agent]
originalAuthor      = []
    , containerAuthor :: [Agent]
containerAuthor     = []
    , collectionEditor :: [Agent]
collectionEditor    = []
    , editorialDirector :: [Agent]
editorialDirector   = []
    , reviewedAuthor :: [Agent]
reviewedAuthor      = []

    , issued :: [RefDate]
issued              = []
    , eventDate :: [RefDate]
eventDate           = []
    , accessed :: [RefDate]
accessed            = []
    , container :: [RefDate]
container           = []
    , originalDate :: [RefDate]
originalDate        = []
    , submitted :: [RefDate]
submitted           = []

    , title :: Formatted
title               = Formatted
forall a. Monoid a => a
mempty
    , titleShort :: Formatted
titleShort          = Formatted
forall a. Monoid a => a
mempty
    , reviewedTitle :: Formatted
reviewedTitle       = Formatted
forall a. Monoid a => a
mempty
    , containerTitle :: Formatted
containerTitle      = Formatted
forall a. Monoid a => a
mempty
    , volumeTitle :: Formatted
volumeTitle         = Formatted
forall a. Monoid a => a
mempty
    , collectionTitle :: Formatted
collectionTitle     = Formatted
forall a. Monoid a => a
mempty
    , containerTitleShort :: Formatted
containerTitleShort = Formatted
forall a. Monoid a => a
mempty
    , collectionNumber :: Formatted
collectionNumber    = Formatted
forall a. Monoid a => a
mempty
    , originalTitle :: Formatted
originalTitle       = Formatted
forall a. Monoid a => a
mempty
    , publisher :: Formatted
publisher           = Formatted
forall a. Monoid a => a
mempty
    , originalPublisher :: Formatted
originalPublisher   = Formatted
forall a. Monoid a => a
mempty
    , publisherPlace :: Formatted
publisherPlace      = Formatted
forall a. Monoid a => a
mempty
    , originalPublisherPlace :: Formatted
originalPublisherPlace = Formatted
forall a. Monoid a => a
mempty
    , authority :: Formatted
authority           = Formatted
forall a. Monoid a => a
mempty
    , jurisdiction :: Formatted
jurisdiction        = Formatted
forall a. Monoid a => a
mempty
    , archive :: Formatted
archive             = Formatted
forall a. Monoid a => a
mempty
    , archivePlace :: Formatted
archivePlace        = Formatted
forall a. Monoid a => a
mempty
    , archiveLocation :: Formatted
archiveLocation     = Formatted
forall a. Monoid a => a
mempty
    , event :: Formatted
event               = Formatted
forall a. Monoid a => a
mempty
    , eventPlace :: Formatted
eventPlace          = Formatted
forall a. Monoid a => a
mempty
    , page :: Formatted
page                = Formatted
forall a. Monoid a => a
mempty
    , pageFirst :: Formatted
pageFirst           = Formatted
forall a. Monoid a => a
mempty
    , numberOfPages :: Formatted
numberOfPages       = Formatted
forall a. Monoid a => a
mempty
    , version :: Formatted
version             = Formatted
forall a. Monoid a => a
mempty
    , volume :: Formatted
volume              = Formatted
forall a. Monoid a => a
mempty
    , numberOfVolumes :: Formatted
numberOfVolumes     = Formatted
forall a. Monoid a => a
mempty
    , issue :: Formatted
issue               = Formatted
forall a. Monoid a => a
mempty
    , chapterNumber :: Formatted
chapterNumber       = Formatted
forall a. Monoid a => a
mempty
    , medium :: Formatted
medium              = Formatted
forall a. Monoid a => a
mempty
    , status :: Formatted
status              = Formatted
forall a. Monoid a => a
mempty
    , edition :: Formatted
edition             = Formatted
forall a. Monoid a => a
mempty
    , section :: Formatted
section             = Formatted
forall a. Monoid a => a
mempty
    , source :: Formatted
source              = Formatted
forall a. Monoid a => a
mempty
    , genre :: Formatted
genre               = Formatted
forall a. Monoid a => a
mempty
    , note :: Formatted
note                = Formatted
forall a. Monoid a => a
mempty
    , annote :: Formatted
annote              = Formatted
forall a. Monoid a => a
mempty
    , abstract :: Formatted
abstract            = Formatted
forall a. Monoid a => a
mempty
    , keyword :: Formatted
keyword             = Formatted
forall a. Monoid a => a
mempty
    , number :: Formatted
number              = Formatted
forall a. Monoid a => a
mempty
    , references :: Formatted
references          = Formatted
forall a. Monoid a => a
mempty
    , url :: Literal
url                 = Literal
forall a. Monoid a => a
mempty
    , doi :: Literal
doi                 = Literal
forall a. Monoid a => a
mempty
    , isbn :: Literal
isbn                = Literal
forall a. Monoid a => a
mempty
    , issn :: Literal
issn                = Literal
forall a. Monoid a => a
mempty
    , pmcid :: Literal
pmcid               = Literal
forall a. Monoid a => a
mempty
    , pmid :: Literal
pmid                = Literal
forall a. Monoid a => a
mempty
    , callNumber :: Literal
callNumber          = Literal
forall a. Monoid a => a
mempty
    , dimensions :: Literal
dimensions          = Literal
forall a. Monoid a => a
mempty
    , scale :: Literal
scale               = Literal
forall a. Monoid a => a
mempty
    , categories :: [Literal]
categories          = [Literal]
forall a. Monoid a => a
mempty
    , language :: Literal
language            = Literal
forall a. Monoid a => a
mempty

    , citationNumber :: CNum
citationNumber           = Int -> CNum
CNum 0
    , firstReferenceNoteNumber :: Int
firstReferenceNoteNumber = 0
    , citationLabel :: CLabel
citationLabel            = CLabel
forall a. Monoid a => a
mempty
    }

numericVars :: [String]
numericVars :: [String]
numericVars = [ "edition", "volume", "number-of-volumes", "number", "issue", "citation-number"
              , "chapter-number", "collection-number", "number-of-pages"]

getReference :: [Reference] -> Cite -> Maybe Reference
getReference :: [Reference] -> Cite -> Maybe Reference
getReference  rs :: [Reference]
rs c :: Cite
c
    = case (String -> Reference -> Bool
hasId (Cite -> String
citeId Cite
c)) (Reference -> Bool) -> [Reference] -> Maybe Reference
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
`find` [Reference]
rs of
        Just r :: Reference
r  -> Reference -> Maybe Reference
forall a. a -> Maybe a
Just (Reference -> Maybe Reference) -> Reference -> Maybe Reference
forall a b. (a -> b) -> a -> b
$ Reference -> Reference
setPageFirst Reference
r
        Nothing -> Maybe Reference
forall a. Maybe a
Nothing
  where hasId :: String -> Reference -> Bool
        hasId :: String -> Reference -> Bool
hasId ident :: String
ident r :: Reference
r = String
ident String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ((Literal -> String) -> [Literal] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Literal -> String
unLiteral (Reference -> Literal
refId Reference
r Literal -> [Literal] -> [Literal]
forall a. a -> [a] -> [a]
: Reference -> [Literal]
refOtherIds Reference
r))

processCites :: [Reference] -> [[Cite]] -> [[(Cite, Maybe Reference)]]
processCites :: [Reference] -> [[Cite]] -> [[(Cite, Maybe Reference)]]
processCites rs :: [Reference]
rs cs :: [[Cite]]
cs
    = [[Cite]] -> [[Cite]] -> [[(Cite, Maybe Reference)]]
procGr [] [[Cite]]
cs
    where
      procRef :: Reference -> Reference
procRef r :: Reference
r = case (Cite -> Bool) -> [Cite] -> [Cite]
forall a. (a -> Bool) -> [a] -> [a]
filter (String -> String -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Literal -> String
unLiteral (Literal -> String) -> Literal -> String
forall a b. (a -> b) -> a -> b
$ Reference -> Literal
refId Reference
r) (String -> Bool) -> (Cite -> String) -> Cite -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cite -> String
citeId) ([Cite] -> [Cite]) -> [Cite] -> [Cite]
forall a b. (a -> b) -> a -> b
$ [[Cite]] -> [Cite]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Cite]]
cs of
                    x :: Cite
x:_ -> Reference
r { firstReferenceNoteNumber :: Int
firstReferenceNoteNumber = String -> Int
readNum (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ Cite -> String
citeNoteNumber Cite
x}
                    []  -> Reference
r

      procGr :: [[Cite]] -> [[Cite]] -> [[(Cite, Maybe Reference)]]
procGr _ [] = []
      procGr acc :: [[Cite]]
acc (x :: [Cite]
x:xs :: [[Cite]]
xs) = let (a' :: [[Cite]]
a',res :: [(Cite, Maybe Reference)]
res) = [[Cite]] -> [Cite] -> ([[Cite]], [(Cite, Maybe Reference)])
procCs [[Cite]]
acc [Cite]
x
                          in [(Cite, Maybe Reference)]
res [(Cite, Maybe Reference)]
-> [[(Cite, Maybe Reference)]] -> [[(Cite, Maybe Reference)]]
forall a. a -> [a] -> [a]
: [[Cite]] -> [[Cite]] -> [[(Cite, Maybe Reference)]]
procGr ([] [Cite] -> [[Cite]] -> [[Cite]]
forall a. a -> [a] -> [a]
: [[Cite]]
a') [[Cite]]
xs

      -- process, given the accumulated history, the current group's cites
      procCs :: [[Cite]] -> [Cite] -> ([[Cite]], [(Cite, Maybe Reference)])
procCs acc :: [[Cite]]
acc [] = ([[Cite]]
acc,[])
      procCs acc :: [[Cite]]
acc (c :: Cite
c:xs :: [Cite]
xs) = let (a :: [[Cite]]
a, rest :: [(Cite, Maybe Reference)]
rest) = [[Cite]] -> [Cite] -> ([[Cite]], [(Cite, Maybe Reference)])
procCs [[Cite]]
addCite [Cite]
xs
                              ref :: Maybe Reference
ref       = Reference -> Reference
procRef (Reference -> Reference) -> Maybe Reference -> Maybe Reference
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Reference] -> Cite -> Maybe Reference
getReference [Reference]
rs Cite
c
                              c' :: Cite
c'        = Cite
c { citePosition :: String
citePosition = String
getCitePosition }
                          in  ([[Cite]]
a, (Cite
c', Maybe Reference
ref) (Cite, Maybe Reference)
-> [(Cite, Maybe Reference)] -> [(Cite, Maybe Reference)]
forall a. a -> [a] -> [a]
: [(Cite, Maybe Reference)]
rest)
          where
            addCite :: [[Cite]]
addCite = case [[Cite]]
acc of
                        []     -> [[Cite
c]]
                        (a:as) -> (Cite
c Cite -> [Cite] -> [Cite]
forall a. a -> [a] -> [a]
: [Cite]
a) [Cite] -> [[Cite]] -> [[Cite]]
forall a. a -> [a] -> [a]
: [[Cite]]
as

            -- http://docs.citationstyles.org/en/stable/specification.html#locators
            getCitePosition :: String
getCitePosition = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
notIbid (Cite -> String
forall p. IsString p => Cite -> p
ibidPosition (Cite -> String) -> Maybe Cite -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Cite
prevSameCite)
                where
                    notIbid :: String
notIbid = if Cite -> String
citeId Cite
c String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (Cite -> String) -> [Cite] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Cite -> String
citeId ([[Cite]] -> [Cite]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Cite]]
acc)
                                 then "subsequent"
                                 else "first"

            ibidPosition :: Cite -> p
ibidPosition x :: Cite
x = let hasL :: Cite -> Bool
hasL k :: Cite
k   = Cite -> String
citeLocator Cite
k String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= ""
                                 withIf :: Bool -> p
withIf b :: Bool
b = if Bool
b then "ibid-with-locator" else "ibid"
                                 diffLoc :: Bool
diffLoc  = Cite -> String
citeLocator Cite
x String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= Cite -> String
citeLocator Cite
c
                                           Bool -> Bool -> Bool
|| Cite -> String
citeLabel Cite
x String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= Cite -> String
citeLabel Cite
c
                             in  case (Cite -> Bool
hasL Cite
x, Cite -> Bool
hasL Cite
c) of
                                   (False, cur :: Bool
cur)  -> Bool -> p
forall p. IsString p => Bool -> p
withIf Bool
cur
                                   (True, True)  -> Bool -> p
forall p. IsString p => Bool -> p
withIf Bool
diffLoc
                                   (True, False) -> "subsequent"

            -- x is previous cite in current group
            -- zs is the previous group
            prevSameCite :: Maybe Cite
prevSameCite = case [[Cite]]
acc of
                             []     -> Maybe Cite
forall a. Maybe a
Nothing
                             (a:as) -> [Cite] -> [[Cite]] -> Maybe Cite
psc [Cite]
a [[Cite]]
as
              where
                -- you can't have an ibid at the start of your document
                psc :: [Cite] -> [[Cite]] -> Maybe Cite
psc [] []     = Maybe Cite
forall a. Maybe a
Nothing

                -- a. the current cite immediately follows on another cite,
                --    within the same citation, that references the same item
                psc (x :: Cite
x:_) _   = if Cite -> String
citeId Cite
c String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== Cite -> String
citeId Cite
x
                                   then Cite -> Maybe Cite
forall a. a -> Maybe a
Just Cite
x
                                   else Maybe Cite
forall a. Maybe a
Nothing

                -- b.  [] => the current cite is the first cite in the citation
                --     zs => and the previous citation consists of a single cite
                --           that refs the same item
                -- The spec appears to be concerned that you cannot know the
                -- correct one to match the locator against.
                -- It is a super clunky if you have [@a, 1; @a, 2] then [@a, 3],
                -- where the second citation gets "subsequent" even though there were
                -- only @a keys.
                -- This is silly. We will use the last one to match against.
                psc [] (zs :: [Cite]
zs:_) = case [Cite]
zs of
                                  [] -> Maybe Cite
forall a. Maybe a
Nothing
                                  (z :: Cite
z:_) -> if (String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== Cite -> String
citeId Cite
c) ((Cite -> String) -> [Cite] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Cite -> String
citeId [Cite]
zs)
                                              then Cite -> Maybe Cite
forall a. a -> Maybe a
Just Cite
z
                                              else Maybe Cite
forall a. Maybe a
Nothing

setPageFirst :: Reference -> Reference
setPageFirst :: Reference -> Reference
setPageFirst ref :: Reference
ref =
  let Formatted ils :: [Inline]
ils = Reference -> Formatted
page Reference
ref
      ils' :: [Inline]
ils' = (Inline -> Bool) -> [Inline] -> [Inline]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (\i :: Inline
i -> Inline
i Inline -> Inline -> Bool
forall a. Eq a => a -> a -> Bool
/= Text -> Inline
Str "–" Bool -> Bool -> Bool
&& Inline
i Inline -> Inline -> Bool
forall a. Eq a => a -> a -> Bool
/= Text -> Inline
Str "-") ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall a b. (a -> b) -> a -> b
$
              (Char -> Bool) -> [Inline] -> [Inline]
splitStrWhen Char -> Bool
isPunctuation [Inline]
ils
  in  if [Inline]
ils [Inline] -> [Inline] -> Bool
forall a. Eq a => a -> a -> Bool
== [Inline]
ils'
         then Reference
ref
         else Reference
ref{ pageFirst :: Formatted
pageFirst = [Inline] -> Formatted
Formatted [Inline]
ils' }

setNearNote :: Style -> [[Cite]] -> [[Cite]]
setNearNote :: Style -> [[Cite]] -> [[Cite]]
setNearNote s :: Style
s cs :: [[Cite]]
cs
    = [Cite] -> [[Cite]] -> [[Cite]]
procGr [] [[Cite]]
cs
    where
      near_note :: Int
near_note   = let nn :: String
nn = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe String -> String)
-> (Style -> Maybe String) -> Style -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [(String, String)] -> Maybe String
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup "near-note-distance" ([(String, String)] -> Maybe String)
-> (Style -> [(String, String)]) -> Style -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Citation -> [(String, String)]
citOptions (Citation -> [(String, String)])
-> (Style -> Citation) -> Style -> [(String, String)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Style -> Citation
citation (Style -> String) -> Style -> String
forall a b. (a -> b) -> a -> b
$ Style
s
                    in  if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
nn then 5 else String -> Int
readNum String
nn
      procGr :: [Cite] -> [[Cite]] -> [[Cite]]
procGr _ [] = []
      procGr a :: [Cite]
a (x :: [Cite]
x:xs :: [[Cite]]
xs) = let (a' :: [Cite]
a',res :: [Cite]
res) = [Cite] -> [Cite] -> ([Cite], [Cite])
procCs [Cite]
a [Cite]
x
                        in [Cite]
res [Cite] -> [[Cite]] -> [[Cite]]
forall a. a -> [a] -> [a]
: [Cite] -> [[Cite]] -> [[Cite]]
procGr [Cite]
a' [[Cite]]
xs

      procCs :: [Cite] -> [Cite] -> ([Cite], [Cite])
procCs a :: [Cite]
a []     = ([Cite]
a,[])
      procCs a :: [Cite]
a (c :: Cite
c:xs :: [Cite]
xs) = ([Cite]
a', Cite
c { nearNote :: Bool
nearNote = Bool
isNear} Cite -> [Cite] -> [Cite]
forall a. a -> [a] -> [a]
: [Cite]
rest)
          where
            (a' :: [Cite]
a', rest :: [Cite]
rest) = [Cite] -> [Cite] -> ([Cite], [Cite])
procCs (Cite
cCite -> [Cite] -> [Cite]
forall a. a -> [a] -> [a]
:[Cite]
a) [Cite]
xs
            isNear :: Bool
isNear     = case (Cite -> Bool) -> [Cite] -> [Cite]
forall a. (a -> Bool) -> [a] -> [a]
filter (String -> String -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Cite -> String
citeId Cite
c) (String -> Bool) -> (Cite -> String) -> Cite -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cite -> String
citeId) [Cite]
a of
                           x :: Cite
x:_ -> Cite -> String
citeNoteNumber Cite
c String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= "0" Bool -> Bool -> Bool
&&
                                  Cite -> String
citeNoteNumber Cite
x String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= "0" Bool -> Bool -> Bool
&&
                                  String -> Int
readNum (Cite -> String
citeNoteNumber Cite
c) Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
readNum (Cite -> String
citeNoteNumber Cite
x) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
near_note
                           _   -> Bool
False

parseRawDate :: String -> [RefDate]
parseRawDate :: String -> [RefDate]
parseRawDate o :: String
o =
  case Parsec String () [RefDate]
-> String -> String -> Either ParseError [RefDate]
forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
P.parse Parsec String () [RefDate]
rawDate "raw date" String
o of
       Left _   -> [Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Season
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing (String -> Literal
Literal String
o) Bool
False]
       Right ds :: [RefDate]
ds -> [RefDate]
ds

rawDate :: P.Parser [RefDate]
rawDate :: Parsec String () [RefDate]
rawDate = Parsec String () [RefDate]
rawDateISO Parsec String () [RefDate]
-> Parsec String () [RefDate] -> Parsec String () [RefDate]
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parsec String () [RefDate]
rawDateOld

parseEDTFDate :: String -> [RefDate]
parseEDTFDate :: String -> [RefDate]
parseEDTFDate o :: String
o =
  case ShowS
handleRanges (ShowS
trim String
o) of
       [] -> []
       o' :: String
o' -> case Parsec String () [RefDate]
-> String -> String -> Either ParseError [RefDate]
forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
P.parse Parsec String () [RefDate]
rawDateISO "date" String
o' of
                Left _   -> []
                Right ds :: [RefDate]
ds -> [RefDate]
ds
    where handleRanges :: ShowS
handleRanges s :: String
s =
            case (Char -> Bool) -> String -> [String]
forall a. (a -> Bool) -> [a] -> [[a]]
splitWhen (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
=='/') String
s of
                 -- 199u EDTF format for a range
                 [x :: String
x] | 'u' Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
x ->
                      (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map (\c :: Char
c -> if Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== 'u' then '0' else Char
c) String
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ "/" String -> ShowS
forall a. [a] -> [a] -> [a]
++
                      (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map (\c :: Char
c -> if Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== 'u' then '9' else Char
c) String
x
                 [x :: String
x, "open"] -> String
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ "/"    -- EDTF
                 [x :: String
x, "unknown"] -> String
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ "/" -- EDTF
                 _  -> String
s

rawDateISO :: P.Parser [RefDate]
rawDateISO :: Parsec String () [RefDate]
rawDateISO = do
  RefDate
d1 <- Parser RefDate
isoDate
  [RefDate]
-> Parsec String () [RefDate] -> Parsec String () [RefDate]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option [RefDate
d1] (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '/' ParsecT String () Identity Char
-> Parsec String () [RefDate] -> Parsec String () [RefDate]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
                  (\x :: RefDate
x -> [RefDate
d1, RefDate
x]) (RefDate -> [RefDate])
-> Parser RefDate -> Parsec String () [RefDate]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                   (  Parser RefDate
isoDate Parser RefDate -> Parser RefDate -> Parser RefDate
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> RefDate -> Parser RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate
emptydate )) Parsec String () [RefDate]
-> ParsecT String () Identity () -> Parsec String () [RefDate]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT String () Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
P.eof
   where emptydate :: RefDate
emptydate = Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Season
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Literal
forall a. Monoid a => a
mempty Bool
False

isoDate :: P.Parser RefDate
isoDate :: Parser RefDate
isoDate = Parser RefDate -> Parser RefDate
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (Parser RefDate -> Parser RefDate)
-> Parser RefDate -> Parser RefDate
forall a b. (a -> b) -> a -> b
$ do
  Bool
extyear <- Bool
-> ParsecT String () Identity Bool
-> ParsecT String () Identity Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option Bool
False (Bool
True Bool
-> ParsecT String () Identity Char
-> ParsecT String () Identity Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char 'y')  -- EDTF year > 4 digits
  -- needed for bibtex
  Maybe Int
y <- do
    String
sign <- String
-> ParsecT String () Identity String
-> ParsecT String () Identity String
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option "" (String -> ParsecT String () Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
P.string "-")
    String
rest <- Int
-> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
P.count 4 ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit
    String
extended <- if Bool
extyear
                   then ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
P.many ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit
                   else String -> ParsecT String () Identity String
forall (m :: * -> *) a. Monad m => a -> m a
return []
    Maybe Int -> ParsecT String () Identity (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> ParsecT String () Identity (Maybe Int))
-> Maybe Int -> ParsecT String () Identity (Maybe Int)
forall a b. (a -> b) -> a -> b
$ case Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ String
sign String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
rest String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
extended) of
                    Just x :: Int
x | Int
x Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 0 -> Int -> Maybe Int
forall a. a -> Maybe a
Just (Int
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)  -- 0 = -1 AD
                    x :: Maybe Int
x               -> Maybe Int
x
  Maybe String
m' <- Maybe String
-> ParsecT String () Identity (Maybe String)
-> ParsecT String () Identity (Maybe String)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option Maybe String
forall a. Maybe a
Nothing (ParsecT String () Identity (Maybe String)
 -> ParsecT String () Identity (Maybe String))
-> ParsecT String () Identity (Maybe String)
-> ParsecT String () Identity (Maybe String)
forall a b. (a -> b) -> a -> b
$ String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> ParsecT String () Identity String
-> ParsecT String () Identity (Maybe String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '-' ParsecT String () Identity Char
-> ParsecT String () Identity String
-> ParsecT String () Identity String
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit)
  (m :: Maybe Int
m,s :: Maybe Season
s) <- case Maybe String
m' Maybe String -> (String -> Maybe Int) -> Maybe Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> (String -> Text) -> String -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack of
                   Just (Int
n::Int)
                          | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 1 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 12  -> (Maybe Int, Maybe Season)
-> ParsecT String () Identity (Maybe Int, Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n, Maybe Season
forall a. Maybe a
Nothing)
                          | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 13 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 16 -> (Maybe Int, Maybe Season)
-> ParsecT String () Identity (Maybe Int, Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int
forall a. Maybe a
Nothing, Int -> Maybe Season
pseudoMonthToSeason Int
n)
                          | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 21 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 24 -> (Maybe Int, Maybe Season)
-> ParsecT String () Identity (Maybe Int, Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int
forall a. Maybe a
Nothing, Int -> Maybe Season
pseudoMonthToSeason Int
n)
                   Nothing | Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
m' -> (Maybe Int, Maybe Season)
-> ParsecT String () Identity (Maybe Int, Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int
forall a. Maybe a
Nothing, Maybe Season
forall a. Maybe a
Nothing)
                   _ -> String -> ParsecT String () Identity (Maybe Int, Maybe Season)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Improper month"
  Maybe Int
d <- Maybe Int
-> ParsecT String () Identity (Maybe Int)
-> ParsecT String () Identity (Maybe Int)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option Maybe Int
forall a. Maybe a
Nothing (ParsecT String () Identity (Maybe Int)
 -> ParsecT String () Identity (Maybe Int))
-> ParsecT String () Identity (Maybe Int)
-> ParsecT String () Identity (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> (String -> Text) -> String -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Maybe Int)
-> ParsecT String () Identity String
-> ParsecT String () Identity (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '-' ParsecT String () Identity Char
-> ParsecT String () Identity String
-> ParsecT String () Identity String
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit)
  Bool -> ParsecT String () Identity ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT String () Identity ())
-> Bool -> ParsecT String () Identity ()
forall a b. (a -> b) -> a -> b
$ case Maybe Int
d of
           Nothing -> Bool
True
           Just (Int
n::Int) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 1 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 31 -> Bool
True
           _ -> Bool
False
  ParsecT String () Identity () -> ParsecT String () Identity ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
P.optional (ParsecT String () Identity () -> ParsecT String () Identity ())
-> ParsecT String () Identity () -> ParsecT String () Identity ()
forall a b. (a -> b) -> a -> b
$ do
    Char
_ <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char 'T'
    String
_ <- ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
P.many (ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ':')
    ParsecT String () Identity String -> ParsecT String () Identity ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
P.optional (ParsecT String () Identity String
 -> ParsecT String () Identity ())
-> ParsecT String () Identity String
-> ParsecT String () Identity ()
forall a b. (a -> b) -> a -> b
$ (String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
P.oneOf "+-" ParsecT String () Identity Char
-> ParsecT String () Identity String
-> ParsecT String () Identity String
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity Char
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 (ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char ':'))
              ParsecT String () Identity String
-> ParsecT String () Identity String
-> ParsecT String () Identity String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> String -> ParsecT String () Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
P.string "Z"
  ()
_ <- ParsecT String () Identity Char -> ParsecT String () Identity ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
P.optional (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '?')
  Bool
c <- Bool
-> ParsecT String () Identity Bool
-> ParsecT String () Identity Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option Bool
False (Bool
True Bool
-> ParsecT String () Identity Char
-> ParsecT String () Identity Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '~')
  RefDate -> Parser RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate :: Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate{ year :: Maybe Int
year = Maybe Int
y, month :: Maybe Int
month = Maybe Int
m,
                  season :: Maybe Season
season = Maybe Season
s, day :: Maybe Int
day = Maybe Int
d,
                  other :: Literal
other = Literal
forall a. Monoid a => a
mempty, circa :: Bool
circa = Bool
c }

rawDateOld :: P.Parser [RefDate]
rawDateOld :: Parsec String () [RefDate]
rawDateOld = do
  let months :: [String]
months   = ["jan","feb","mar","apr","may","jun","jul","aug",
                  "sep","oct","nov","dec"]
  let seasons :: [String]
seasons  = ["spr","sum","fal","win"]
  let pmonth :: ParsecT String u Identity (Maybe Int)
pmonth = ParsecT String u Identity (Maybe Int)
-> ParsecT String u Identity (Maybe Int)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String u Identity (Maybe Int)
 -> ParsecT String u Identity (Maybe Int))
-> ParsecT String u Identity (Maybe Int)
-> ParsecT String u Identity (Maybe Int)
forall a b. (a -> b) -> a -> b
$ do
        String
xs <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.letter ParsecT String u Identity String
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit
        if (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isDigit String
xs
           then case Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (String -> Text
T.pack String
xs) of
                      Just (Int
n::Int) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 1 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 12 -> Maybe Int -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n)
                      _ -> String -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Improper month"
           else case String -> [String] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
elemIndex ((Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Int -> ShowS
forall a. Int -> [a] -> [a]
take 3 String
xs) [String]
months of
                     Nothing -> String -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Improper month"
                     Just n :: Int
n  -> Maybe Int -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Maybe Int
forall a. a -> Maybe a
Just (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+1))
  let pseason :: ParsecT String u Identity (Maybe Season)
pseason = ParsecT String u Identity (Maybe Season)
-> ParsecT String u Identity (Maybe Season)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String u Identity (Maybe Season)
 -> ParsecT String u Identity (Maybe Season))
-> ParsecT String u Identity (Maybe Season)
-> ParsecT String u Identity (Maybe Season)
forall a b. (a -> b) -> a -> b
$ do
        String
xs <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.letter
        case String -> [String] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
elemIndex ((Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Int -> ShowS
forall a. Int -> [a] -> [a]
take 3 String
xs) [String]
seasons of
             Just 0  -> Maybe Season -> ParsecT String u Identity (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Spring)
             Just 1  -> Maybe Season -> ParsecT String u Identity (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Summer)
             Just 2  -> Maybe Season -> ParsecT String u Identity (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Autumn)
             Just 3  -> Maybe Season -> ParsecT String u Identity (Maybe Season)
forall (m :: * -> *) a. Monad m => a -> m a
return (Season -> Maybe Season
forall a. a -> Maybe a
Just Season
Winter)
             _       -> String -> ParsecT String u Identity (Maybe Season)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Improper season"
  let pday :: ParsecT String u Identity (Maybe Int)
pday = ParsecT String u Identity (Maybe Int)
-> ParsecT String u Identity (Maybe Int)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String u Identity (Maybe Int)
 -> ParsecT String u Identity (Maybe Int))
-> ParsecT String u Identity (Maybe Int)
-> ParsecT String u Identity (Maybe Int)
forall a b. (a -> b) -> a -> b
$ do
        String
xs <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit
        case Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (String -> Text
T.pack String
xs) of
             Just (Int
n::Int) | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 1 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 31 -> Maybe Int -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n)
             _ -> String -> ParsecT String u Identity (Maybe Int)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "Improper day"
  let pyear :: ParsecT String u Identity (Maybe Int)
pyear = Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> (String -> Text) -> String -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Maybe Int)
-> ParsecT String u Identity String
-> ParsecT String u Identity (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
P.many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
P.digit
  let sep :: ParsecT String u Identity ()
sep = String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
P.oneOf [' ','/',','] ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
P.spaces
  let rangesep :: ParsecT String u Identity ()
rangesep = ParsecT String u Identity () -> ParsecT String u Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try (ParsecT String u Identity () -> ParsecT String u Identity ())
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b. (a -> b) -> a -> b
$ ParsecT String u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
P.spaces ParsecT String u Identity ()
-> ParsecT String u Identity Char -> ParsecT String u Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
P.char '-' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
P.spaces
  let refDate :: RefDate
refDate = Maybe Int
-> Maybe Int
-> Maybe Season
-> Maybe Int
-> Literal
-> Bool
-> RefDate
RefDate Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Season
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Literal
forall a. Monoid a => a
mempty Bool
False
  let date :: ParsecT String u Identity RefDate
date = [ParsecT String u Identity RefDate]
-> ParsecT String u Identity RefDate
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
P.choice ([ParsecT String u Identity RefDate]
 -> ParsecT String u Identity RefDate)
-> [ParsecT String u Identity RefDate]
-> ParsecT String u Identity RefDate
forall a b. (a -> b) -> a -> b
$ (ParsecT String u Identity RefDate
 -> ParsecT String u Identity RefDate)
-> [ParsecT String u Identity RefDate]
-> [ParsecT String u Identity RefDate]
forall a b. (a -> b) -> [a] -> [b]
map ParsecT String u Identity RefDate
-> ParsecT String u Identity RefDate
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
P.try
                [ do Maybe Season
s <- ParsecT String u Identity (Maybe Season)
forall u. ParsecT String u Identity (Maybe Season)
pseason
                     ParsecT String u Identity ()
forall u. ParsecT String u Identity ()
sep
                     Maybe Int
y <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pyear
                     RefDate -> ParsecT String u Identity RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate
refDate{ year :: Maybe Int
year = Maybe Int
y, season :: Maybe Season
season = Maybe Season
s }
                , do Maybe Int
m <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pmonth
                     ParsecT String u Identity ()
forall u. ParsecT String u Identity ()
sep
                     Maybe Int
d <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pday
                     ParsecT String u Identity ()
forall u. ParsecT String u Identity ()
sep
                     Maybe Int
y <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pyear
                     RefDate -> ParsecT String u Identity RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate
refDate{ year :: Maybe Int
year = Maybe Int
y, month :: Maybe Int
month = Maybe Int
m, day :: Maybe Int
day = Maybe Int
d }
                , do Maybe Int
m <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pmonth
                     ParsecT String u Identity ()
forall u. ParsecT String u Identity ()
sep
                     Maybe Int
y <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pyear
                     RefDate -> ParsecT String u Identity RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate
refDate{ year :: Maybe Int
year = Maybe Int
y, month :: Maybe Int
month = Maybe Int
m }
                , do Maybe Int
y <- ParsecT String u Identity (Maybe Int)
forall u. ParsecT String u Identity (Maybe Int)
pyear
                     RefDate -> ParsecT String u Identity RefDate
forall (m :: * -> *) a. Monad m => a -> m a
return RefDate
refDate{ year :: Maybe Int
year = Maybe Int
y }
                ]
  RefDate
d1 <- Parser RefDate
forall u. ParsecT String u Identity RefDate
date
  [RefDate]
-> Parsec String () [RefDate] -> Parsec String () [RefDate]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
P.option [RefDate
d1] ((\x :: RefDate
x -> [RefDate
d1,RefDate
x]) (RefDate -> [RefDate])
-> Parser RefDate -> Parsec String () [RefDate]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT String () Identity ()
forall u. ParsecT String u Identity ()
rangesep ParsecT String () Identity () -> Parser RefDate -> Parser RefDate
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser RefDate
forall u. ParsecT String u Identity RefDate
date))