{- |
Module : Data.Graph.Analysis.Reporting
Description : Graphalyze Types and Classes
Copyright : (c) Ivan Lazar Miljenovic 2008
License : 2-Clause BSD
Maintainer : Ivan.Miljenovic@gmail.com
This module defines the report framework used.
-}moduleData.Graph.Analysis.Reporting(-- * Document representation-- $documentDocument(..),DocumentGenerator(..),Location(..),DocElement(..),DocInline(..),DocGraph,-- * Helper functions-- $utilitiestoday,tryCreateDirectory,createGraph)whereimportData.GraphVizimportData.Graph.Analysis.VisualisationimportData.TimeimportControl.ExceptionimportSystem.DirectoryimportSystem.FilePathimportSystem.Locale-- -----------------------------------------------------------------------------{- $document
'Document' is the simplified representation of a document. Note
that this just specifies a document layout, and not an
implementation. To actually create a \"physical\" document,
you must use an instance of 'DocumentGenerator'.
-}{- | Representation of a document. The document is to be stored in
the directory 'rootDirectory', and the main file is to have a
filename of @'fileFront' '<.>' ('docExtension' dg)@, where @dg@ is an
instance of 'DocumentGenerator'.
-}dataDocument=Doc{-- | Document locationrootDirectory::FilePath,fileFront::String,-- | Pre-mattertitle::DocInline,author::String,date::String,-- | Main-mattercontent::[DocElement]}-- | Represents the class of document generators.classDocumentGeneratordgwhere-- | Convert idealised 'Document' values into actual documents,-- returning the document file created.createDocument::dg->Document->IO(MaybeFilePath)-- | The extension of all document-style files created. Note that-- this doesn't preclude the creation of other files, e.g. images.docExtension::dg->String-- | Representation of a location, either on the internet or locally.dataLocation=URLString|FileFilePathinstanceShowLocationwhereshow(URLurl)=urlshow(Filefp)=fp-- | Elements of a document.dataDocElement=SectionDocInline[DocElement]|Paragraph[DocInline]|Enumeration[DocElement]|Itemized[DocElement]|DefinitionDocInlineDocElement|DocImageDocInlineLocation|GraphImageDocGraphdataDocInline=TextString|BlankSpace|Grouping[DocInline]|BoldDocInline|EmphasisDocInline|DocLinkDocInlineLocationtypeDocGraph=(FilePath,DocInline,DotGraph)-- -----------------------------------------------------------------------------{- $utilities
Utility functions to help with document creation.
-}-- | Return today's date as a string, e.g. \"Monday 1 January, 2000\".-- This arbitrary format is chosen as there doesn't seem to be a way-- of determining the correct format as per the user's locale settings.today::IOStringtoday=dozoneT<-getZonedTimeletlocalT=zonedTimeToLocalTimezoneTreturn$formatTimelocalefmtlocalTwherelocale=defaultTimeLocalefmt="%A %e %B, %Y"-- | Attempts to create the specified directly, returning @True@-- if successful (or if the directory already exists), @False@-- if an error occurred.tryCreateDirectory::FilePath->IOBooltryCreateDirectoryfp=dor<-try$mkDirfpreturn(isRightr)wheremkDir=createDirectoryIfMissingTrueisRight(Right_)=TrueisRight_=False-- | Attempts to creates a png file (with the given filename in the-- given directory) and - if successful - returns a 'DocImage' link.createGraph::FilePath->DocGraph->IO(MaybeDocElement)createGraphfp(fn,inl,dg)=docreated<-runGraphvizdgoutputfilename'ifcreatedthenreturn(Justimg)elsereturnNothingwhereext="png"output=Pngfilename=fn<.>extfilename'=fp</>filenameloc=Filefilenameimg=DocImageinlloc