-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRaw.hs
More file actions
23 lines (21 loc) · 778 Bytes
/
Raw.hs
File metadata and controls
23 lines (21 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- | pretty print top down representations
{-# LANGUAGE OverloadedStrings #-}
module Topdown.Raw where
import Topdown.Core
import Data.Text.Prettyprint.Doc
import StringEscape (escape)
import Data.ByteString.Conversion (toByteString)
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.UTF8 as BLU
instance Topdown ByteString where
tfFloat = toByteString
tfInt = toByteString
tfStr = toByteString . escape
tfBool True = "True"
tfBool False = "False"
tfUnit = "None"
tfCons n xs = BLU.fromString n <> "(" <> B.intercalate "," xs <> ")"
tfSeq xs = "[" <> B.intercalate "," xs <> "]"
tfVar = BLU.fromString
tfAcc subject attr = subject <> "." <> BLU.fromString attr