Skip to content

Instantly share code, notes, and snippets.

@enolan
Created April 19, 2009 05:09
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 enolan/97930 to your computer and use it in GitHub Desktop.
Save enolan/97930 to your computer and use it in GitHub Desktop.
data BEncode = BInt Integer
| BString ByteString
| BList [BEncode]
| BDict (Map ByteString BEncode)
deriving (Eq, Ord, Show)
getInt i = case i of
BInt i' -> Just i'
_ -> Nothing
getString s = case s of
BString s' -> Just s'
_ -> Nothing
getList l = case l of
BList l' -> Just l'
_ -> Nothing
getDict d = case d of
BDict d' -> Just d'
_ -> Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment