haskelzinc-0.2.0.1: CP in Haskell through MiniZinc

Copyright(c) Some Guy, 2013 Someone Else, 2014
LicenseBSD3
MaintainerKlara Marntirosian <klara.mar@cs.kuleuven.be>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Interfaces.MZPrinter

Description

This module provides a pretty-printer of MiniZinc models represented through the MZAST module. This pretty-printer is based on the Text.PrettyPrint module.

Synopsis

Documentation

type MZModel = [Item] Source #

An abbreviation for the type of a represented MiniZinc model.

printModel :: MZModel -> Doc Source #

Prints the represented MiniZinc model. Essentially, this function applies printItem on each element of the specified model.

printItem :: Item -> Doc Source #

Prints an item of the represented model. Example:

>>> printItem $ Pred "even" [(Dec, Int, "x")] (Just (Bi Eq (Bi Mod (Var "x") (IConst 2)) (IConst 0)))
predicate even(var int: x) =
  x mod 2 = 0;

printExpr :: Expr -> Doc Source #

Prints the represented MiniZinc expressions of a model. Examples:

>>> printExpr $ SetComp (Bi Times (IConst 2) (Var "i")) ([(["i"], Interval (IConst 1) (IConst 5))], Nothing)
{2 * i | i in 1..5}
>>> printExpr $ Let [Declare Dec Int "x" (Just (IConst 3)), Declare Dec Int "y" (Just (IConst 4))] (Bi BPlus (Var "x") (Var "y"))
let {var int: x = 3;
     var int: y = 4;}
in x + y