Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created January 27, 2018 20:43
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/b1185398719f5932b6906396fb67a9f9 to your computer and use it in GitHub Desktop.
Save Icelandjack/b1185398719f5932b6906396fb67a9f9 to your computer and use it in GitHub Desktop.
GHC Trac 14661
class ListLike f where
  nil  :: f a
  cons :: a -> f a -> f a
  (·)  :: f a -> f a -> f a

newtype LL a = LL (forall ff. ListLike ff => ff a)

instance ListLike LL where
  nil :: LL a
  nil = LL nil
  
  cons :: a -> LL a -> LL a
  cons a (LL as) = LL (cons a as)
  
  (·) :: LL a -> LL a -> LL a
  LL as · LL bs = LL (as · bs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment