
On Wed, Aug 15, 2012 at 12:54 PM, Christian Maeder
Well, "Either" was an adhoc choice and should be application specific. Another h98 solution would be to keep the common part in a single constructor:
data UserOrAppData = AppData | UserData UserId UTCTime data AccessToken = AccessToken UserOrAppData AccessTokenData
This is a non-solution since you can't specify anymore that you want an user access token but not an app access token.
or: data AccessToken a = AccessToken a AccessTokenData
And this one brings us the Either again (although on fewer places). Most functions would be able to get a `AccessToken a` because they don't care about what you called `UserData` above. However, some other functions (such as isValid) do care about that and would need `Either (AccessToken AppData) (AccessToken UserData)`. That's not to say that we *couldn't* avoid GADTs. We certainly could. But GADTs allow us to have our cake and eat it, too =). Cheers, -- Felipe.