module Language.Drasil.Printing.Import.Citation where
import Control.Lens ((^.))
import Drasil.Database (showUID)
import Language.Drasil (Citation, CiteField(..), HP (..), citeKind, HasFields (..))
import qualified Language.Drasil.Printing.AST as P
import qualified Language.Drasil.Printing.Citation as P
layCite :: Citation -> P.Citation
layCite :: Citation -> Citation
layCite Citation
c = EntryID -> CitationKind -> [CiteField] -> Citation
P.Cite (Citation -> EntryID
forall a. HasUID a => a -> EntryID
showUID Citation
c) (Citation
c Citation
-> Getting CitationKind Citation CitationKind -> CitationKind
forall s a. s -> Getting a s a -> a
^. Getting CitationKind Citation CitationKind
Lens' Citation CitationKind
citeKind) ((CiteField -> CiteField) -> [CiteField] -> [CiteField]
forall a b. (a -> b) -> [a] -> [b]
map CiteField -> CiteField
layField (Citation
c Citation -> Getting [CiteField] Citation [CiteField] -> [CiteField]
forall s a. s -> Getting a s a -> a
^. Getting [CiteField] Citation [CiteField]
forall c. HasFields c => Lens' c [CiteField]
Lens' Citation [CiteField]
getFields))
layField :: CiteField -> P.CiteField
layField :: CiteField -> CiteField
layField (Address EntryID
s) = Spec -> CiteField
P.Address (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
s
layField (Author People
p) = People -> CiteField
P.Author People
p
layField (BookTitle EntryID
b) = Spec -> CiteField
P.BookTitle (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
b
layField (Chapter Int
c) = Int -> CiteField
P.Chapter Int
c
layField (Edition Int
e) = Int -> CiteField
P.Edition Int
e
layField (Editor People
e) = People -> CiteField
P.Editor People
e
layField (Institution EntryID
i) = Spec -> CiteField
P.Institution (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
i
layField (Journal EntryID
j) = Spec -> CiteField
P.Journal (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
j
layField (Month Month
m) = Month -> CiteField
P.Month Month
m
layField (Note EntryID
n) = Spec -> CiteField
P.Note (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
n
layField (Number Int
n) = Int -> CiteField
P.Number Int
n
layField (Organization EntryID
o) = Spec -> CiteField
P.Organization (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
o
layField (Pages [Int]
p) = [Int] -> CiteField
P.Pages [Int]
p
layField (Publisher EntryID
p) = Spec -> CiteField
P.Publisher (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
p
layField (School EntryID
s) = Spec -> CiteField
P.School (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
s
layField (Series EntryID
s) = Spec -> CiteField
P.Series (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
s
layField (Title EntryID
t) = Spec -> CiteField
P.Title (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
t
layField (Type EntryID
t) = Spec -> CiteField
P.Type (Spec -> CiteField) -> Spec -> CiteField
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
t
layField (Volume Int
v) = Int -> CiteField
P.Volume Int
v
layField (Year Int
y) = Int -> CiteField
P.Year Int
y
layField (HowPublished (URL EntryID
u)) = HP -> CiteField
P.HowPublished (Spec -> HP
P.URL (Spec -> HP) -> Spec -> HP
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
u)
layField (HowPublished (Verb EntryID
v)) = HP -> CiteField
P.HowPublished (Spec -> HP
P.Verb (Spec -> HP) -> Spec -> HP
forall a b. (a -> b) -> a -> b
$ EntryID -> Spec
P.S EntryID
v)