Keep a social journal of your work progress as you make and learn things.


I was supposed to finish the #MidnightMurderParty editor UI tonight, but I got distracted and spent 5 hours making a type system for my Google API FFI. The API code now has two main types, Gapi and AccessToken.

These types then contain (sort of) other types. For example, an access token retrieved with the “drive.readonly” and “email” scopes will have the type AccessToken (driveReadOnly :: DriveReadOnlyScope, email :: EmailScope) where DriveReadOnlyScope and EmailScope are also types. This way I can prevent passing an access token without the right set of scopes into an API call on the type level; it becomes a compiler error instead of a runtime error!

The Gapi type tracks functions involving Google’s gapi variable such that the compiler will stop me from using features I haven’t set up yet. A completely set up Gapi type for this app looks like: Gapi (auth2 :: Auth2 Ready, filepicker :: GooglePickerObject).

Way cooler than a UI. 😁