Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created February 12, 2015 10:59
Show Gist options
  • Save chadaustin/af10b5214f6adf9b8ead to your computer and use it in GitHub Desktop.
Save chadaustin/af10b5214f6adf9b8ead to your computer and use it in GitHub Desktop.
vector :: (GVector.Vector v a, ToJson a) => v a -> JsonBuilder
vector !vec = JsonBuilder $ do
BB.appendChar8 '['
when (GVector.length vec /= 0) $ do
unJsonBuilder $ appendJson (vec `GVector.unsafeIndex` 0)
GVector.forM_ vec $ \e -> do
BB.appendChar8 ','
unJsonBuilder $ appendJson e
BB.appendChar8 ']'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment