{-# Language TemplateHaskell #-}
module Language.Drasil.DecoratedReference (
DecRef(..),
HasDecRef(..),
dRef, dRefInfo
) where
import Language.Drasil.Sentence (RefInfo(..))
import Language.Drasil.Reference (Reference, ref)
import Language.Drasil.Label.Type (HasRefAddress(..))
import Language.Drasil.ShortName (HasShortName(..))
import Language.Drasil.UID (HasUID(..))
import Control.Lens ((^.), makeLenses, Lens')
data DecRef = DR {
DecRef -> Reference
_rf :: Reference,
DecRef -> RefInfo
refInfo :: RefInfo
}
makeLenses ''DecRef
class HasDecRef c where
getDecRefs :: Lens' c [DecRef]
instance Eq DecRef where DecRef
a == :: DecRef -> DecRef -> Bool
== DecRef
b = (DecRef
a forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid) forall a. Eq a => a -> a -> Bool
== (DecRef
b forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid)
instance HasUID DecRef where uid :: Lens' DecRef UID
uid = Lens' DecRef Reference
rf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasUID c => Lens' c UID
uid
instance HasRefAddress DecRef where getRefAdd :: DecRef -> LblType
getRefAdd (DR Reference
r RefInfo
_) = forall b. HasRefAddress b => b -> LblType
getRefAdd Reference
r
instance HasShortName DecRef where shortname :: DecRef -> ShortName
shortname (DR Reference
r RefInfo
_) = forall s. HasShortName s => s -> ShortName
shortname Reference
r
dRefInfo :: (HasUID r, HasRefAddress r, HasShortName r) => r -> RefInfo -> DecRef
dRefInfo :: forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> RefInfo -> DecRef
dRefInfo r
r = Reference -> RefInfo -> DecRef
DR (forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Reference
ref r
r)
dRef :: (HasUID r, HasRefAddress r, HasShortName r) => r -> DecRef
dRef :: forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef r
r = forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> RefInfo -> DecRef
dRefInfo r
r RefInfo
None