Skip to content

Instantly share code, notes, and snippets.

@rblaze
Created May 28, 2013 11:57
Show Gist options
  • Save rblaze/5662226 to your computer and use it in GitHub Desktop.
Save rblaze/5662226 to your computer and use it in GitHub Desktop.
[1 of 1] Compiling Test ( Test.hs, Test.o )
Test.hs:17:10:
Illegal instance declaration for `Heap (CacheHeap h) a'
(the Coverage Condition fails for one of the functional dependencies;
Use -XUndecidableInstances to permit this)
In the instance declaration for `Heap (CacheHeap h) a'
{-# LANGUAGE GADTs, MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}
module Test where
class Ord a => Heap h a | h -> a where
empty :: h
insert :: a -> h -> h
findMin :: h -> Maybe a
deleteMin :: h -> h
toList :: h -> [a]
fromList :: [a] -> h
fromList = foldr insert empty
data CacheHeap h where
KacheHeap :: (Heap h a) => h -> Maybe a -> CacheHeap h
instance (Heap h a) => Heap (CacheHeap h) a where
empty = KacheHeap (empty :: h a) Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment