-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrettyPrint.hs
61 lines (47 loc) · 1.92 KB
/
PrettyPrint.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- =============================================================
-- ===== Módulo para imprimir visualmente en el intérprete =====
-- =============================================================
module PrettyPrint where
-- Módulos propios
import Common
-- Módulos prestados
import Text.PrettyPrint.HughesPJ as PJ
-- Definición de tipos de datos --
----------------------------------
type Solution = (Float, Float)
-- Funciones --
---------------
printSolution :: Solution -> Doc
printSolution (solx, soly) = text "\nSe requiere una plancha de ancho " <>
float solx <>
text " y largo " <>
float soly <>
text "\n"
printContainer :: Container -> Doc
printContainer c = text ((nc c) ++ " ") <>
parens (int (rid c)) <>
text " : " <>
float (abs (p1x c - p2x c)) <>
text " x " <>
float (abs (p1y c - p2y c))
printContainers cs = printList cs printContainer
printMyPointL' :: [MyPoint] -> Doc
printMyPointL' [] = text ""
printMyPointL' [p] = parens (float (fst p) <>
text "," <>
float (snd p))
printMyPointL' (p1:(p2:mp)) = parens (float (fst p1) <>
text "," <>
float (snd p1)) <>
text ", " <>
printMyPointL' (p2:mp)
printPolygon :: Polygon -> Doc
printPolygon po = text (pn po) <>
text " : " <>
brackets (printMyPointL' (p po))
printPolygons ps = printList ps printPolygon
printList :: [a] -> (a -> Doc) -> Doc
printList [] _ = text ""
printList (x:xs) f = f x <>
text "\n" <>
printList xs f