Created
August 19, 2012 20:51
-
-
Save zsol/3397650 to your computer and use it in GitHub Desktop.
PSQueue stack overflow
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
import Data.PSQueue | |
data Element = E Int String deriving (Show) | |
type Buffer = PSQ Int Element | |
instance Eq Element where | |
(E a _) == (E b _) = a == b | |
instance Ord Element where | |
(E a _) < (E b _) = a < b | |
alterEl :: Element -> Maybe Element -> Maybe Element | |
alterEl el Nothing = Just el | |
-- alterEl (E newint newstring) (Just (E oldint oldstring)) = Just $ E oldint newstring | |
a = alter (alterEl $ E 0 "zero") 0 empty | |
b = alter (alterEl $ E 1 "one") 1 a | |
-- print b causes a stack overflow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment