| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.EO.Phi.Syntax
Synopsis
- module Language.EO.Phi.Syntax.Abs
- desugar :: Object -> Object
- printTree :: (Pretty a, SugarableFinally a) => a -> String
- printTreeDontSugar :: Pretty a => a -> String
- intToBytes :: Int -> Bytes
- int64ToBytes :: Int64 -> Bytes
- int32ToBytes :: Int32 -> Bytes
- int16ToBytes :: Int16 -> Bytes
- floatToBytes :: Double -> Bytes
- boolToBytes :: Bool -> Bytes
- stringToBytes :: String -> Bytes
- bytesToInt :: Bytes -> Int
- bytesToInt64 :: Bytes -> Int64
- bytesToInt32 :: Bytes -> Int32
- bytesToInt16 :: Bytes -> Int16
- bytesToFloat :: Bytes -> Double
- bytesToString :: Bytes -> String
- bytesToBool :: Bytes -> Bool
- wrapBytesInConstInt :: Bytes -> Object
- wrapBytesInConstInt64 :: Bytes -> Object
- wrapBytesInConstInt32 :: Bytes -> Object
- wrapBytesInConstInt16 :: Bytes -> Object
- wrapBytesInConstFloat :: Bytes -> Object
- wrapBytesInConstString :: Bytes -> Object
- wrapBytesInBytes :: Bytes -> Object
- wrapBytesInInt :: Bytes -> Object
- wrapBytesInFloat :: Bytes -> Object
- wrapBytesAsBool :: Bytes -> Object
- wrapBytesInString :: Bytes -> Object
- wrapTermination :: Object
- sliceBytes :: Bytes -> Int -> Int -> Bytes
- concatBytes :: Bytes -> Bytes -> Bytes
- chunksOf :: Int -> [a] -> [[a]]
- paddedLeftChunksOf :: a -> Int -> [a] -> [[a]]
- normalizeBytes :: String -> String
- parseWith :: (DesugarableInitially a, CheckableSyntaxInitially a) => ([Token] -> Either String a) -> String -> Either String a
- errorExpectedDesugaredObject :: Object -> a
- errorExpectedDesugaredBinding :: Binding -> a
- errorExpectedDesugaredAttribute :: Attribute -> a
- class SugarableFinally a where
- sugarFinally :: a -> a
- pattern AlphaBinding' :: Attribute -> Object -> Binding
- pattern AlphaBinding'' :: LabelId -> [Attribute] -> Object -> Binding
Documentation
module Language.EO.Phi.Syntax.Abs
printTreeDontSugar :: Pretty a => a -> String Source #
Conversion to Bytes
intToBytes :: Int -> Bytes Source #
int64ToBytes :: Int64 -> Bytes Source #
int32ToBytes :: Int32 -> Bytes Source #
int16ToBytes :: Int16 -> Bytes Source #
floatToBytes :: Double -> Bytes Source #
Encode Double as Bytes following IEEE754.
Note: it is called "float" in EO, but it actually occupies 8 bytes so it corresponds to Double.
>>>floatToBytes 0Bytes "00-00-00-00-00-00-00-00"
>>>floatToBytes (-0.1)Bytes "BF-B9-99-99-99-99-99-9A"
>>>floatToBytes (1/0) -- InfinityBytes "7F-F0-00-00-00-00-00-00"
>>>floatToBytes (asin 2) `elem` ["FF-F8-00-00-00-00-00-00", "7F-F8-00-00-00-00-00-00"] -- sNaN or qNaNTrue
boolToBytes :: Bool -> Bytes Source #
stringToBytes :: String -> Bytes Source #
Conversion from Bytes
bytesToInt :: Bytes -> Int Source #
bytesToInt64 :: Bytes -> Int64 Source #
bytesToInt32 :: Bytes -> Int32 Source #
bytesToInt16 :: Bytes -> Int16 Source #
bytesToFloat :: Bytes -> Double Source #
bytesToString :: Bytes -> String Source #
bytesToBool :: Bytes -> Bool Source #
Wrapping Bytes into Object
wrapBytesInConstInt :: Bytes -> Object Source #
wrapBytesInConstInt64 :: Bytes -> Object Source #
wrapBytesInConstInt32 :: Bytes -> Object Source #
wrapBytesInConstInt16 :: Bytes -> Object Source #
wrapBytesInConstFloat :: Bytes -> Object Source #
wrapBytesInConstString :: Bytes -> Object Source #
wrapBytesInBytes :: Bytes -> Object Source #
wrapBytesInInt :: Bytes -> Object Source #
wrapBytesInFloat :: Bytes -> Object Source #
wrapBytesAsBool :: Bytes -> Object Source #
wrapBytesInString :: Bytes -> Object Source #
Functions over Bytes
sliceBytes :: Bytes -> Int -> Int -> Bytes Source #
Select a slice (section) of Bytes.
>>>sliceBytes "12-34-56" 1 1Bytes "34-"
>>>sliceBytes "12-34-56" 1 0Bytes "00-"
>>>sliceBytes "12-34-56" 0 2Bytes "12-34"
concatBytes :: Bytes -> Bytes -> Bytes Source #
Concatenate Bytes.
FIXME: we should really use ByteString instead of the underlying String representation.
>>>concatBytes "00-" "01-02"Bytes "00-01-02"
>>>concatBytes "03-04" "01-02"Bytes "03-04-01-02"
>>>concatBytes "03-04" "01-"Bytes "03-04-01"
Helpers
chunksOf :: Int -> [a] -> [[a]] Source #
Split a list into chunks of given size. All lists in the result are guaranteed to have length less than or equal to the given size.
>>>chunksOf 2 "012345678"["01","23","45","67","8"]
See paddedLeftChunksOf for a version with padding to guarantee exact chunk size.
paddedLeftChunksOf :: a -> Int -> [a] -> [[a]] Source #
Split a list into chunks of given size, padding on the left if necessary. All lists in the result are guaranteed to have given size.
>>>paddedLeftChunksOf '0' 2 "1234567"["01","23","45","67"]>>>paddedLeftChunksOf '0' 2 "123456"["12","34","56"]
n > 0 ==> all (\chunk -> length chunk == n) (paddedLeftChunksOf c n s)
normalizeBytes :: String -> String Source #
Normalize the bytestring representation to fit valid Bytes token.
>>>normalizeBytes "238714ABCDEF""23-87-14-AB-CD-EF"
>>>normalizeBytes "0238714ABCDEF""00-23-87-14-AB-CD-EF"
>>>normalizeBytes "4""04-"
parseWith :: (DesugarableInitially a, CheckableSyntaxInitially a) => ([Token] -> Either String a) -> String -> Either String a Source #
errorExpectedDesugaredObject :: Object -> a Source #
errorExpectedDesugaredBinding :: Binding -> a Source #
Classes
class SugarableFinally a where Source #
Minimal complete definition
Nothing
Methods
sugarFinally :: a -> a Source #
Instances
Pattern synonyms
Orphan instances
| IsString Attribute Source # | |
Methods fromString :: String -> Attribute # | |
| IsString AttributeSugar Source # | |
Methods fromString :: String -> AttributeSugar # | |
| IsString Binding Source # | |
Methods fromString :: String -> Binding # | |
| IsString MetaId Source # | |
Methods fromString :: String -> MetaId # | |
| IsString Object Source # | |
Methods fromString :: String -> Object # | |
| IsString ObjectHead Source # | |
Methods fromString :: String -> ObjectHead # | |
| IsString PeeledObject Source # | |
Methods fromString :: String -> PeeledObject # | |
| IsString Program Source # | |
Methods fromString :: String -> Program # | |
| IsString RuleAttribute Source # | |
Methods fromString :: String -> RuleAttribute # | |