bookmark

ANN: typed sprintf and sscanf in haskell w specification as 1st class value


Description

demonstrates that sprintf and sscanf can indeed use exactly the same formatting specification, which is a first-class value. We demonstrate typed sprintf and typed sscanf sharing the same formatting specification. Our solution is surprisingly trivial: it defines a simple embedded domain-specific language of formatting patterns. The functions sprintf and sscanf are two interpreters of the language, to build or parse a string according to the given pattern. Our solution relies only on GADTs. We demonstrate that lambda-abstractions at the type level are expressible already in the Hindley-Milner type system; GADT with the included polymorphic recursion help us use the abstractions.

Preview

Tags

Users

  • @draganigajic

Comments and Reviews