How can I declare an instance of FromJSON of the following data type:
data Privacy = Everyone |
AllFriends |
FriendsOfFriends |
Self
So that the following string to enumerated data type is honored:
"EVERYONE" -> Everyone
"ALL_FRIENDS" -> AllFriends
"FRIENDS_OF_FRIENDS" -> FriendsOfFriends
"SELF" -> Self
_ -> Parsing error
A possible solution is hinted here, but I cannot make that code compile.
Thanks!
The FromJSON definition should read:
Complete working example: