diff --git a/diagrams-lib.cabal b/diagrams-lib.cabal index 664a7c38..9cab7fe5 100644 --- a/diagrams-lib.cabal +++ b/diagrams-lib.cabal @@ -33,6 +33,7 @@ Library Diagrams.Attributes, Diagrams.Attributes.Compile, Diagrams.Backend.CmdLine, + Diagrams.Backend.Build, Diagrams.BoundingBox, Diagrams.Combinators, Diagrams.Coordinates, diff --git a/src/Diagrams/Backend/Build.hs b/src/Diagrams/Backend/Build.hs new file mode 100644 index 00000000..872a6281 --- /dev/null +++ b/src/Diagrams/Backend/Build.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Diagrams.Builder.Class +-- Copyright : (c) 2014 diagrams-lib team (see LICENSE) +-- License : BSD-style (see LICENSE) +-- Maintainer : diagrams-discuss@googlegroups.com +-- +-- General class for building diagrams to files. +-- +----------------------------------------------------------------------------- +module Diagrams.Backend.Build where + +import Diagrams.Core +import Diagrams.Size +import Data.Monoid (Any) +import Linear.V2 +import Control.Lens (Lens') + +-- | Generic class for building diagrams whose output is a file with a +-- 2D size. +class Backend b v n => BackendBuild b v n where + -- | Lens onto the size of the output file. + outputSize :: Lens' (Options b v n) (SizeSpec V2 n) + + -- | Build a diagram of the given format to the path using the + -- backend's options. The @Maybe String@ returns any errors. + saveDia :: FilePath -> Options b v n -> QDiagram b v n Any -> IO () +