summaryrefslogtreecommitdiff
path: root/src/GF/Data
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-02-23 12:42:44 +0000
committerkrasimir <krasimir@chalmers.se>2009-02-23 12:42:44 +0000
commit01fef5109c2920d13004ae5b94d192fa5fba205f (patch)
treea5211ace0573bbe5397b68681d1949889f73a000 /src/GF/Data
parent2bc918bb9a6489d5f40993c8417b147ffc375472 (diff)
Perhaps -> Maybe refactoring and better error message for conflicts during module update
Diffstat (limited to 'src/GF/Data')
-rw-r--r--src/GF/Data/Operations.hs50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/GF/Data/Operations.hs b/src/GF/Data/Operations.hs
index bd5d6f452..7b2afc9fe 100644
--- a/src/GF/Data/Operations.hs
+++ b/src/GF/Data/Operations.hs
@@ -26,11 +26,6 @@ module GF.Data.Operations (-- * misc functions
-- ** checking
checkUnique,
- -- * a three-valued maybe type to express indirections
- Perhaps(..), yes, may, nope,
- mapP,
- unifPerhaps, updatePerhaps, updatePerhapsHard,
-
-- * binary search trees; now with FiniteMap
BinTree, emptyBinTree, isInBinTree, justLookupTree,
lookupTree, lookupTreeMany, lookupTreeManyAll, updateTree,
@@ -127,51 +122,6 @@ checkUnique ss = ["overloaded" +++ show s | s <- nub overloads] where
overloads = filter overloaded ss
overloaded s = length (filter (==s) ss) > 1
--- | a three-valued maybe type to express indirections
-data Perhaps a b = Yes a | May b | Nope deriving (Show,Read,Eq,Ord)
-
-yes :: a -> Perhaps a b
-yes = Yes
-
-may :: b -> Perhaps a b
-may = May
-
-nope :: Perhaps a b
-nope = Nope
-
-mapP :: (a -> c) -> Perhaps a b -> Perhaps c b
-mapP f p = case p of
- Yes a -> Yes (f a)
- May b -> May b
- Nope -> Nope
-
--- | this is what happens when matching two values in the same module
-unifPerhaps :: (Eq a, Eq b, Show a, Show b) =>
- Perhaps a b -> Perhaps a b -> Err (Perhaps a b)
-unifPerhaps p1 p2 = case (p1,p2) of
- (Nope, _) -> return p2
- (_, Nope) -> return p1
- _ -> if p1==p2 then return p1
- else Bad ("update conflict between" ++++ show p1 ++++ show p2)
-
--- | this is what happens when updating a module extension
-updatePerhaps :: (Eq a,Eq b, Show a, Show b) =>
- b -> Perhaps a b -> Perhaps a b -> Err (Perhaps a b)
-updatePerhaps old p1 p2 = case (p1,p2) of
- (Yes a, Nope) -> return $ may old
- (May older,Nope) -> return $ may older
- (_, May a) -> Bad "strange indirection"
- _ -> unifPerhaps p1 p2
-
--- | here the value is copied instead of referred to; used for oper types
-updatePerhapsHard :: (Eq a, Eq b, Show a, Show b) => b ->
- Perhaps a b -> Perhaps a b -> Err (Perhaps a b)
-updatePerhapsHard old p1 p2 = case (p1,p2) of
- (Yes a, Nope) -> return $ yes a
- (May older,Nope) -> return $ may older
- (_, May a) -> Bad "strange indirection"
- _ -> unifPerhaps p1 p2
-
-- binary search trees
type BinTree a b = Map a b