Skip to content

Instantly share code, notes, and snippets.

@jayunit100
Created October 30, 2014 00:15
Show Gist options
  • Save jayunit100/ec3e997d9bf3e85efee9 to your computer and use it in GitHub Desktop.
Save jayunit100/ec3e997d9bf3e85efee9 to your computer and use it in GitHub Desktop.
~ |355 instance Read Color where
~ |356 readsPrec _ value =
~ |357 tryParse [("Red", Red), ("Green", Green), ("Blue", Blue)]
~ |358 where tryParse [] = []
~ |359 tryParse ((attempt, result):xs) =
~ |360 if (take (length attempt) value ) == attempt
~ |361 then [(result, drop (length attempt))]
~ |362 else tryParse xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment