Skip to content

Instantly share code, notes, and snippets.

@m-renaud
Created September 7, 2017 16:23
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 m-renaud/970493ebbc96b58234cdee21077e0747 to your computer and use it in GitHub Desktop.
Save m-renaud/970493ebbc96b58234cdee21077e0747 to your computer and use it in GitHub Desktop.
data Entry = Entry
{ entryState :: EntryState
, entryPayload :: Maybe Payload
}
data EntryState = NO_ENTRY | IN_PROGRESS | HAS_ENTRY
data Cache = ...
lookup :: Cache -> Key -> Entry
lookupIfKeyPresent :: Cache -> Maybe Key -> Entry
lookupIfKeyPresent _ Nothing = Entry NO_ENTRY Nothing
lookupIfKeyPresent cache (Just k) = lookup cache k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment