-----------------------------------------------------------------------------
-- Copyright 2019, Advise-Me project team. This file is distributed under 
-- the terms of the Apache License 2.0. For more information, see the files
-- "LICENSE.txt" and "NOTICE.txt", which are included in the distribution.
-----------------------------------------------------------------------------
-- |
-- Maintainer  :  bastiaan.heeren@ou.nl
-- Stability   :  provisional
-- Portability :  portable (depends on ghc)
--
-- Prettyprinting for commonly used datatypes.
--
-----------------------------------------------------------------------------

module Util.Pretty where

import Text.PrettyPrint.Leijen ( (<$$>) )
import qualified Data.Map as M
import qualified Text.PrettyPrint.Leijen as PP

prettyMap :: (PP.Pretty a, PP.Pretty b) => M.Map a b -> PP.Doc
prettyMap = (<$$> PP.empty)
          . PP.vsep
          . map (\(k,v) -> PP.empty <$$> PP.pretty k <$$> PP.indent 4 (PP.pretty v))
          . M.toList