The final view to the typed sprintf and sscanf
http://okmij.org/ftp/typed-formatting/FPrintScan.html
This code defines a simple domain-specific language of string patterns and demonstrates two interpreters of the language: for building strings (sprintf) and parsing strings (sscanf). This code thus solves the problem of typed printf/scanf sharing the same format string posed by Chung-chieh Shan. This code presents scanf/printf interpreters in the final style; it is thus the dual of the code in PrintScan.hs
Version: The current version is 1.1, Sep 2, 2008.
References
- The complete Haskell98 code with many examples. http://okmij.org/ftp/typed-formatting/PrintScanF.hs
- The final view on typed sprintf and sscanf http://okmij.org/ftp/typed-formatting/PrintScanF.txt
- The message posted on the Haskell mailing list on Tue, 2 Sep 2008 00:57:18 -0700 (PDT)
Documentation
class FormattingSpec repr whereSource
data PrinterParser a Source
PrinterParser (a -> String) (String -> Maybe (a, String)) |
fmt :: (FormattingSpec repr, Show b, Read b) => b -> repr a (b -> a)Source
showread :: (Show a, Read a) => PrinterParser aSource