Riddle me this

Posted in haskell
8 comments on “Riddle me this
  1. sclv says:

    this is a terrible hack, but no more of a hack than printf itself:

    test :: (HPrintfType r, NoOp r) => Bool -> Handle -> String -> r
    test b = if b then hPrintf
    else nopr

    class NoOp a where
    nopr :: a

    instance NoOp (IO a) where
    nopr = return undefined

    instance (NoOp r) => NoOp (a -> r) where
    nopr = const $ nopr

    don’t have an answer for the second bit at the moment tho.

  2. brian says:

    Don’t forget package ‘xformat’.

  3. Saizan says:

    I got a solution requiring more extensions but that it looks more general, here’s the paste:
    http://hpaste.org/fastcgi/hpaste.fcgi/view?id=9857

    The types, especially those inferred like in test, aren’t so pretty but not horrible either.

  4. Saizan: Wow, that’s impressive. Type signatures longer than the code they describe? Eeek!

  5. Saizan says:

    well, the typeclass system is what’s doing most of the work 😛

  6. Ajaj says:

    When my son was born his middle name was to be after my feahtr in law and it was not a cool name Ned. I waited until an hour before I left the hospital to finish the birth certificate paperwork because it wasn’t my favorite name at all, but I wanted to honor my feahtr in law. Maybe that’s what took her so long debating do I go with nicer sounding names, or go with my heart? so then the newspaper went and printed his name as Cotton Ned , instead of Colton Ned as it should have been. NICE!

  7. I've always wanted to set a book in Spain at the time of the Reconquista (Christians drove the Moors south to Granada).Another interesting period would be 1492, when Ferdinand and Isabella expelled the remaining Moors AND the Jews from Spain.

  8. Ooooo I am an ANGEL! And the winds screams… untill you give me something to belive in, and untill you give me something to stick my teeth in. The winds cry SM guld and I be there for you.Now lets finsh what we started!

1 Pings/Trackbacks for "Riddle me this"
  1. […] little while ago, Bryan O’Sullivan was developing his Criterion benchmark suite, and had trouble with using the Text.Printf module in a monad transformer on top of IO. I thought I knew how to solve this, but my first idea didn’t work — and nor did my […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*