[Haskell-cafe] Re: [Haskell] The initial view on typed sprintf and sscanf

Ryan Ingram ryani.spam at gmail.com
Mon Sep 1 05:08:42 EDT 2008


On Mon, Sep 1, 2008 at 1:30 AM, Bulat Ziganshin
<bulat.ziganshin at gmail.com> wrote:
> of course this may be done with code generation tools (such as TH).
> point of this research is to do this using type abilities of Haskell

Yes, I know.  My point was that TH could be used as a minimal "String
-> ExpQ" wrapper, where the ExpQ is the code used by this library, to
save keystrokes.

I'm all about writing 100 lines of code to save 10 keystrokes per use
of a function. :)

> Don, i think this should be impossible with IsString since the point
> is that Haskell compiler should know types at compile time. IsString
> can't convert "%d" into (X int) while converting "%s" into (X String)

Although of course you could use IsString to convert raw strings into
'lit "string"'; this would make the syntax slightly more palatable:

> printf ("hello" ^ char ^ "world" ^ char) ' ' '!'

  -- ryan


More information about the Haskell-Cafe mailing list