Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt
Created April 13, 2018 23:18
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 parsonsmatt/a814e5c73756cc315fe3417110a5b9a2 to your computer and use it in GitHub Desktop.
Save parsonsmatt/a814e5c73756cc315fe3417110a5b9a2 to your computer and use it in GitHub Desktop.
maybe your thinking, "wow, i really want a type class with only two instances" well here you go!! don't export the class and you're *golden*. i mean, write a better error message, but come on
-- gross hack so i can lighten the syntax load
class NameOrEntityRef x where
disambiguate :: x -> Either Name EntityRef
instance NameOrEntityRef Name where
disambiguate = Left
instance NameOrEntityRef EntityRef where
disambiguate = Right
instance {-# OVERLAPPABLE #-} (TypeError (Text "No.")) => NameOrEntityRef a where
disambiguate = undefined
@taktoa
Copy link

taktoa commented Apr 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment