Precision value for floating point numbers.
Modulehosc-0.20Haskell2010
Sound.Osc.Text
A simple and unambigous text encoding for Osc.
- 2 types
- 32 values
- Packagehosc-0.20
- Exports34
- LanguageHaskell2010
- LicenceGPL-3.0-only
- SourceText.hs
Variant of showFFloat that deletes trailing zeros.
map (showFloatWithPrecision (Just 4)) [1, 2.0, pi] == ["1.0", "2.0", "3.1416"]Hex encoded byte sequence.
showBytes [0, 15, 16, 144, 255] == "000f1090ff"Escape whites space (space, tab, newline) and the escape character (backslash).
mapM_ (putStrLn . escapeString) ["str", "str ", "st r", "s\tr", "s\\tr", "\nstr"]Printer for Datum.
aDatumSeq = [Int32 1,Float 1.2,string "str",midi (0,0x90,0x40,0x60),blob [12,16], TimeStamp 100.0]
map (showDatum (Just 5)) aDatumSeq == ["1","1.2","str","00904060","0c10","429496729600"]Printer for Message.
aMessage = Message "/addr" [Int32 1, Int64 2, Float 3, Double 4, string "five", blob [6, 7], midi (8, 9, 10, 11)]
showMessage (Just 4) aMessageaMessageSeq = [Message "/c_set" [Int32 1, Float 2.3], Message "/s_new" [string "sine", Int32 (-1), Int32 1, Int32 1]]
map (showMessage (Just 4)) aMessageSeqPrinter for Bundle
aBundle = Bundle 1 [Message "/c_set" [Int32 1, Float 2.3, Int64 4, Double 5.6], Message "/memset" [string "addr", blob [7, 8]]]
showBundle (Just 4) aBundlePrinter for Packet.
Parser
26 declarationsA character parser with no user state.
Run p then q, returning result of p.
p as lexeme, i.e. consuming any trailing white space.
Any non-space character. Allow escaped space.
Parser for string.
Parser for Osc address.
Parser for Osc signature.
Parser for decimal digit.
Parser for non-negative integer.
Parser for integer.
Parser for non-negative float.
Parser for non-negative float.
Parser for hexadecimal digit.
Byte parser.
Byte sequence parser.
Datum parser.
Message parser.
Bundle tag parser.
Bundle parser.
Packet parser.
Run parser.
Run datum parser.
parseDatum 'i' "-1" == Int32 (-1)
parseDatum 'f' "-2.3" == Float (-2.3)Run message parser.
aMessageSeq = [Message "/c_set" [Int32 1, Float 2.3, Int64 4, Double 5.6], Message "/memset" [string "addr", blob [7, 8]]]
map (parseMessage . showMessage (Just 4)) aMessageSeq == aMessageSeqRun bundle parser.
aBundle = Bundle 1 [Message "/c_set" [Int32 1, Float 2.3, Int64 4, Double 5.6], Message "/memset" [string "addr", blob [7, 8]]]
parseBundle (showBundle (Just 4) aBundle) == aBundleRun packet parser.
aPacket = Packet_Bundle (Bundle 1 [Message "/c_set" [Int32 1, Float 2.3, Int64 4, Double 5.6], Message "/memset" [string "addr", blob [7, 8]]])
parsePacket (showPacket (Just 4) aPacket) == aPacket