1signature MATH_PENALTY  =
2sig
3  val mathPenalty:  bool -> MathTypes.kind -> IListTypes.ilist -> BoxTypes.hlist
4end  (* signature MATH_PENALTY *)
5(*----------*)
6
7structure MathPenalty: MATH_PENALTY  =
8struct
9  open BoxTypes;  open MathTypes;  open IListTypes
10  open Const
11
12  val allowPenalty  =
13  fn []                   =>  false
14  |  IPen _         :: _  =>  false
15  |  INoad (Rel, _) :: _  =>  false
16  |  _                    =>  true
17
18  fun makeList pen  =  if  pen = infPenalty  then  []  else  [Penalty pen]
19
20  fun penaltyList Bin  =  makeList binopPenalty
21  |   penaltyList Rel  =  makeList relPenalty
22  |   penaltyList  _   =  []
23
24  fun mathPenalty false _       _          =  []
25  |   mathPenalty true  actKind restIList  =
26        if  allowPenalty restIList  then  penaltyList actKind  else  []
27end  (* structure MathPenalty *)
28