Simple String aliasing to prepare the day when we'll be able to have more complex Component than just PDF Names (and access elements in an array)
This commit is contained in:
parent
cb257fc07e
commit
4969c6442e
1 changed files with 5 additions and 4 deletions
|
@ -41,6 +41,7 @@ newtype Error a = Error {
|
||||||
} deriving (Alternative, Functor, Applicative, Monad, MonadPlus)
|
} deriving (Alternative, Functor, Applicative, Monad, MonadPlus)
|
||||||
instance MonadFail Error where
|
instance MonadFail Error where
|
||||||
fail = Error . Left
|
fail = Error . Left
|
||||||
|
type Component = String
|
||||||
|
|
||||||
getDictionary :: PDFContent m => Object -> m Dictionary
|
getDictionary :: PDFContent m => Object -> m Dictionary
|
||||||
getDictionary (Direct (Dictionary aDict)) = return aDict
|
getDictionary (Direct (Dictionary aDict)) = return aDict
|
||||||
|
@ -64,21 +65,21 @@ objectById objectId = do
|
||||||
layer <- ask
|
layer <- ask
|
||||||
return (objects layer ! objectId)
|
return (objects layer ! objectId)
|
||||||
|
|
||||||
(./) :: PDFContent m => m Object -> String -> m Object
|
(./) :: PDFContent m => m Object -> Component -> m Object
|
||||||
(./) object key = (object >>= getDictionary >>= getField key >>= castObject)
|
(./) object key = (object >>= getDictionary >>= getField key >>= castObject)
|
||||||
where
|
where
|
||||||
castObject (Reference (IndirectObjCoordinates {objectId})) =
|
castObject (Reference (IndirectObjCoordinates {objectId})) =
|
||||||
objectById objectId
|
objectById objectId
|
||||||
castObject directObject = return $ Direct directObject
|
castObject directObject = return $ Direct directObject
|
||||||
|
|
||||||
(//) :: PDFContent m => m Object -> [String] -> m Object
|
(//) :: PDFContent m => m Object -> [Component] -> m Object
|
||||||
(//) object [] = object
|
(//) object [] = object
|
||||||
(//) object (key:keys) = object ./ key // keys
|
(//) object (key:keys) = object ./ key // keys
|
||||||
|
|
||||||
(>./) :: PDFContent m => Object -> String -> m Object
|
(>./) :: PDFContent m => Object -> Component -> m Object
|
||||||
(>./) object = (return object ./)
|
(>./) object = (return object ./)
|
||||||
|
|
||||||
(>//) :: PDFContent m => Object -> [String] -> m Object
|
(>//) :: PDFContent m => Object -> [Component] -> m Object
|
||||||
(>//) object = (return object //)
|
(>//) object = (return object //)
|
||||||
|
|
||||||
origin :: PDFContent m => m Object
|
origin :: PDFContent m => m Object
|
||||||
|
|
Loading…
Reference in a new issue