Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created March 9, 2017 01:53
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 Icelandjack/e77a5f0e2cef21b47a1a707e80bed7c0 to your computer and use it in GitHub Desktop.
Save Icelandjack/e77a5f0e2cef21b47a1a707e80bed7c0 to your computer and use it in GitHub Desktop.
Musings on One / Zero

Representable

data One a = One
  deriving Functor

instance Distributive One where
  distribute :: Functor f => f (One a) -> One (f a)
  distribute _ = One

instance Representable One where
  type Rep One = Void

  index :: One a -> Void -> a
  index One = absurd

  tabulate :: (Void -> a) -> One a
  tabulate _ = One

Share Product Notation

Write it as

data () a = One
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment