Skip to content

Instantly share code, notes, and snippets.

@plaidfinch
Last active August 29, 2015 14:12
Show Gist options
  • Save plaidfinch/f9e0de5114abf24c5c41 to your computer and use it in GitHub Desktop.
Save plaidfinch/f9e0de5114abf24c5c41 to your computer and use it in GitHub Desktop.
List of Dicts?
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
import Data.Constraint
import Data.Proxy
data Product (f :: k -> *) (xs :: [k]) where
(:*:) :: f x -> Product f xs -> Product f (x ': xs)
Nil :: Product f '[]
type family All (c :: k -> Constraint) (xs :: [k]) :: Constraint where
All c '[] = ()
All c (x ': xs) = (c x, All c xs)
newtype Compose f g a = Compose { getCompose :: f (g a) }
dicts :: All c xs => Proxy c -> Product Proxy xs -> Product (Compose Dict c) xs
dicts = _
@plaidfinch
Copy link
Author

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