[Haskell-cafe] Parsing binary 'hierachical' objects for lazy developers

Stephen Tetley stephen.tetley at gmail.com
Wed Apr 27 21:52:22 CEST 2011

John Meacham's DrIFT tool used to get extended faster than GHC for
things that "should" be automatic. I'm not sure of its current status,


For your second problem, something like this:

getAB :: Get (Either A B)
getAB = do
  len <- getWord16be
  tag <- getWord16be
  if tag == 0x00 then do { a <- getA len; return (Left a) }
	         else do { a <- getB len; return (Right b) }

-- length already consumed so sent as an argument...

getA :: Word16 -> Get A
getB :: Word16 -> Get B

More information about the Haskell-Cafe mailing list