-
Notifications
You must be signed in to change notification settings - Fork 5
/
pdfmills.hs
39 lines (29 loc) · 908 Bytes
/
pdfmills.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
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ExistentialQuantification #-}
module Main where
-- Ignore this
main :: IO ()
main = return ()
data Font = Font String Int Int
data Text = Text String Font
newtype Space = Space Int
data Image = Image String Int Int
data Drawn a = Drawn
vertical :: BoundingBox -> Int
vertical (Box _ y _ h) = y + h
class Drawable a where
draw :: a -> Drawn a
-- Rules
-- * (width . draw) a == width a
-- * (height . draw) a == height a
class Drawable a => Element a where
width :: BoundingBox -> a -> Int
height :: BoundingBox -> a -> Int
class Element a => Layout a where
boxes :: a -> [BoundingBox]
data BoundingBox = Box Int Int Int Int
data BasicLayout a where
BlockLayout :: Element a => [a] -> BasicLayout a
InlineLayout :: Element a => [a] -> BasicLayout a
newtype FlexLayout a = FlexLayout [BasicLayout a]
newtype TableLayout a = TableLayout [FlexLayout a]