Commit 9be2048e authored by Steffen Michels's avatar Steffen Michels

add gEq/gLexOrd instance for Data.Set

parent c28cd6c8
Pipeline #8763 passed with stage
in 1 minute and 25 seconds
......@@ -5,6 +5,8 @@ from StdClass import class Ord (..), <=, >
from Data.Maybe import :: Maybe
from Data.List import foldl, map
from StdBool import not, &&
from Data.Generics.GenEq import generic gEq
from Data.Generics.GenLexOrd import generic gLexOrd, :: LexOrd
// This module is ported from Haskell Data.Set by László Domoszlai. 2013.sep.6
......@@ -47,8 +49,9 @@ from StdBool import not, &&
| Bin !Int !a !(Set a) !(Set a)
instance == (Set a) | == a
instance < (Set a) | < a
derive gEq Set
derive gLexOrd Set
/**
* True iff this is the empty set.
......
implementation module Data.Set
import StdClass, StdMisc, StdBool, StdList, StdFunc, StdInt, StdTuple
import Data.Maybe
import Data.Maybe, Data.Generics.GenEq, Data.Generics.GenLexOrd
//mapSet :: !(a -> b) !(Set a) -> Set b | < a & == a & < b & == b
//mapSet f s = fromList (map f (toList s))
......@@ -34,6 +34,9 @@ instance < (Set a) | < a where
| a > b = False
| otherwise = compare as bs
gEq{|Set|} eEq x y = (size x == size y) && gEq{|* -> *|} eEq (toAscList x) (toAscList y)
gLexOrd{|Set|} eLexOrd x y = gLexOrd{|* -> *|} eLexOrd (toAscList x) (toAscList y)
/*--------------------------------------------------------------------
* Query
*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment