Created
May 28, 2013 11:57
-
-
Save rblaze/5662226 to your computer and use it in GitHub Desktop.
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
[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' |
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 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