Last active
August 29, 2015 14:10
-
-
Save CRogers/2b595e4401f9bfc707a4 to your computer and use it in GitHub Desktop.
Ambiguity error with higher order lists and type families
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE KindSignatures, DataKinds, TypeFamilies, TypeOperators, GADTs, FlexibleInstances, FlexibleContexts #-} | |
module Foo where | |
data HList as where | |
HNil :: HList '[] | |
HCons :: a -> HList as -> HList (a ': as) | |
instance Show (HList '[]) where | |
show _ = "[]" | |
instance (Show a, Show (HList as)) => Show (HList (a ': as)) where | |
show (HCons a as) = show a ++ ":" ++ show as | |
first :: HList (a ': as) -> HList '[a] | |
first (HCons a _) = HCons a HNil | |
newtype Cat a = Cat a | |
type family MapCat (as :: [*]) :: [*] where | |
MapCat '[] = '[] | |
MapCat (a ': as) = Cat a ': MapCat as | |
type CatList cs = HList (MapCat cs) | |
first' :: CatList (a ': as) -> CatList '[a] | |
first' (HCons a _) = HCons a HNil |
Author
CRogers
commented
Nov 30, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment