Skip to content

Instantly share code, notes, and snippets.

@tsurushuu
Created September 25, 2011 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsurushuu/1240228 to your computer and use it in GitHub Desktop.
Save tsurushuu/1240228 to your computer and use it in GitHub Desktop.
fromResult :: Result a -> Maybe a
fromResult (Ok k) = Just k
fromResult (Error e) = Nothing
maybeFromObj :: JSON a => String -> JSObject JSValue -> Maybe a
maybeFromObj k o = maybe (Nothing) (fromResult . readJSON) (lookup k (fromJSObject o))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment