Safe Haskell | None |
---|---|
Language | Haskell2010 |
- readRawIpeFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpeFile r))
- readIpeFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpeFile r))
- readSinglePageFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpePage r))
- type ConversionError = Text
- fromIpeXML :: (Coordinate r, IpeRead (t r)) => ByteString -> Either ConversionError (t r)
- readXML :: ByteString -> Either ConversionError (Node Text Text)
- class IpeReadText t where
- ipeReadText :: Text -> Either ConversionError t
- class IpeRead t where
- class IpeReadAttr t where
- ipeReadAttr :: Text -> Node Text Text -> Either ConversionError t
- ipeReadTextWith :: (Text -> Either t v) -> Text -> Either ConversionError (IpeValue v)
- ipeReadObject :: (IpeRead (i r), f ~ AttrMapSym1 r, ats ~ AttributesOf i, RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => Proxy i -> proxy r -> Node Text Text -> Either ConversionError (i r :+ IpeAttributes i r)
- ipeReadAttrs :: forall proxy proxy' i r f ats. (f ~ AttrMapSym1 r, ats ~ AttributesOf i, RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => proxy i -> proxy' r -> Node Text Text -> Either ConversionError (IpeAttributes i r)
- ipeReadRec :: forall f ats. (RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => Proxy f -> Proxy ats -> Node Text Text -> Either ConversionError (Rec (Attr f) ats)
Reading ipe Files
readRawIpeFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpeFile r)) Source
Given a file path, tries to read an ipe file
readIpeFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpeFile r)) Source
Given a file path, tries to read an ipe file. This function applies all matrices to objects.
readSinglePageFile :: Coordinate r => FilePath -> IO (Either ConversionError (IpePage r)) Source
Since most Ipe file contain only one page, we provide a shortcut for that as well. This function applies all matrices.
type ConversionError = Text Source
Reading XML directly
fromIpeXML :: (Coordinate r, IpeRead (t r)) => ByteString -> Either ConversionError (t r) Source
Given a Bytestring, try to parse the bytestring into anything that is IpeReadable, i.e. any of the Ipe elements.
readXML :: ByteString -> Either ConversionError (Node Text Text) Source
Reads the data from a Bytestring into a proper Node
Read classes
class IpeReadText t where Source
Reading an ipe elemtn from a Text value
ipeReadText :: Text -> Either ConversionError t Source
IpeReadText Int Source | |
IpeReadText Text Source | |
IpeReadText FillType Source | |
IpeReadText IpeColor Source | |
IpeReadText TransformationTypes Source | |
IpeReadText PinType Source | |
IpeReadText LayerName Source | |
Coordinate r => IpeReadText [Operation r] Source | |
Coordinate r => IpeReadText (NonEmpty (PathSegment r)) Source | |
Coordinate r => IpeReadText (IpeArrow r) Source | |
Coordinate r => IpeReadText (IpeDash r) Source | |
Coordinate r => IpeReadText (IpePen r) Source | |
Coordinate r => IpeReadText (IpeSize r) Source | |
Coordinate r => IpeReadText (Path r) Source | |
Coordinate r => IpeReadText (Point 2 r) Source | |
Coordinate r => IpeReadText (Rectangle () r) Source | |
Coordinate r => IpeReadText (Matrix 3 3 r) Source | |
Coordinate r => IpeReadText (PolyLine 2 () r) Source |
Reading an ipe lement from Xml
IpeRead LayerName Source | |
IpeRead View Source | |
Coordinate r => IpeRead (Image r) Source | |
Coordinate r => IpeRead (IpeSymbol r) Source | Ipe read instances |
Coordinate r => IpeRead (MiniPage r) Source | |
Coordinate r => IpeRead (TextLabel r) Source | |
Coordinate r => IpeRead (PathSegment r) Source | |
Coordinate r => IpeRead (Path r) Source | |
Coordinate r => IpeRead (IpeObject r) Source | |
Coordinate r => IpeRead (Group r) Source | |
Coordinate r => IpeRead (IpePage r) Source | |
Coordinate r => IpeRead (IpeFile r) Source | |
Coordinate r => IpeRead (PolyLine 2 () r) Source |
class IpeReadAttr t where Source
Basically IpeReadText for attributes. This class is not really meant to be
implemented directly. Just define an IpeReadText instance for the type
(Apply f at), then the generic instance below takes care of looking up the
name of the attribute, and calling the right ipeReadText value. This class
is just so that reifyConstraint in ipeReadRec
can select the right
typeclass when building the rec.
ipeReadAttr :: Text -> Node Text Text -> Either ConversionError t Source
IpeReadText (Apply * k f at) => IpeReadAttr (Attr k f at) Source |
Some low level implementation functions
ipeReadTextWith :: (Text -> Either t v) -> Text -> Either ConversionError (IpeValue v) Source
ipeReadObject :: (IpeRead (i r), f ~ AttrMapSym1 r, ats ~ AttributesOf i, RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => Proxy i -> proxy r -> Node Text Text -> Either ConversionError (i r :+ IpeAttributes i r) Source
If we can ipeRead an ipe element, and we can ipeReadAttrs its attributes we can properly read an ipe object using ipeReadObject
ipeReadAttrs :: forall proxy proxy' i r f ats. (f ~ AttrMapSym1 r, ats ~ AttributesOf i, RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => proxy i -> proxy' r -> Node Text Text -> Either ConversionError (IpeAttributes i r) Source
Reader for records. Given a proxy of some ipe type i, and a proxy of an coordinate type r, read the IpeAttributes for i from the xml node.
ipeReadRec :: forall f ats. (RecApplicative ats, RecAll (Attr f) ats IpeReadAttr, AllSatisfy IpeAttrName ats) => Proxy f -> Proxy ats -> Node Text Text -> Either ConversionError (Rec (Attr f) ats) Source
Reading the Attributes into a Rec (Attr f), all based on the types of f (the type family mapping labels to types), and a list of labels (ats).