forsyde-deep-0.2.0: src/ForSyDe/Deep/Backend/VHDL/FileIO.hs
-----------------------------------------------------------------------------
-- |
-- Module : ForSyDe.Deep.Backend.VHDL.FileIO
-- Copyright : (c) ES Group, KTH/ICT/ES 2007-2013
-- License : BSD-style (see the file LICENSE)
--
-- Maintainer : forsyde-dev@ict.kth.se
-- Stability : experimental
-- Portability : portable
--
-- Functions working with files in the VHDL backend.
--
-----------------------------------------------------------------------------
module ForSyDe.Deep.Backend.VHDL.FileIO (writeDesignFile) where
import ForSyDe.Deep.Backend.VHDL.AST
import ForSyDe.Deep.Backend.VHDL.Ppr() -- instances
import qualified ForSyDe.Deep.Backend.Ppr as ForSyDePpr (ppr)
import System.IO
import Text.PrettyPrint.HughesPJ
-- | Write a design file to a file in disk
writeDesignFile :: DesignFile -> FilePath -> IO ()
writeDesignFile df fp = do
handle <- openFile fp WriteMode
hPutStrLn handle "-- Automatically generated by ForSyDe"
hPutStr handle $ (renderStyle mystyle . ForSyDePpr.ppr) df
hClose handle
where mystyle = style{lineLength=80, ribbonsPerLine=1}