/
GInstr.hs
37 lines (32 loc) · 837 Bytes
/
GInstr.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
module GInstr (GInstr (..), GProgram, toByteCode) where
import FastString (FastString)
import qualified FastString as FS
import Data.Char
data GInstr = BLACK
| RED
| GREEN
| YELLOW
| BLUE
| MAGENTA
| CYAN
| WHITE
| TRANSPARENT
| OPAQUE
| EMPTY_BUCKET
| MOVE
| TURN_ANTI_CLOCKWISE
| TURN_CLOCKWISE
| MARK
| LINE
| FILL
| ADD_BITMAP
| COMPOSE
| CLIP
| NOOP
deriving (Show, Eq, Enum)
type GProgram = [GInstr]
toByteCode :: GProgram -> FastString
toByteCode prog = bc' prog FS.empty
where
bc' [] acc = acc
bc' (x:xs) acc = bc' xs $! (FS.snoc acc (chr (fromEnum x)))