Skip to content

Instantly share code, notes, and snippets.

@zsol
Created August 19, 2012 20:51
Show Gist options
  • Save zsol/3397650 to your computer and use it in GitHub Desktop.
Save zsol/3397650 to your computer and use it in GitHub Desktop.
PSQueue stack overflow
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