Check for exhaustive patterns continued
An atttempt to attach a file to the last submission
resulted in the
following message from Netscape (?):
Fatal error: Call to a member function on a
non-object in common/tracker/ArtifactFile.class on
line 106
So I include the file below (the line numbers will be
changed),
================================
module See where
data Tree key value
= EMPTY
| TREE key value (Tree key value) (Tree
key value)
insert :: ( Ord key ) =>
key -> value -> -- insert this
new key and value
Tree key value -> -- into this
tree
Maybe (Tree key value) -- to form (Just
new tree ),
--
or Nothing if key is present
insert k v EMPTY = Just (TREE k v EMPTY EMPTY)
insert k v (TREE k' v' left right)
| k < k' = case insert k v left of
Nothing -> Nothing
Just left' -> Just (TREE k' v'
left' right)
| k > k' = case insert k v right of
Nothing -> Nothing
Just right' -> Just (TREE k' v'
left right')
| k == k' = Nothing
-- Same with a case expression:
insert' :: ( Ord key ) =>
key -> value -> Tree key value -> Maybe
(Tree key value)
insert' k v t =
case t of
EMPTY -> Just (TREE k v EMPTY EMPTY)
(TREE k' v' left right)
| k < k' -> case insert' k v left of
Nothing -> Nothing
Just left' -> Just (TREE
k' v' left' right)
| k > k' -> case insert' k v right of
Nothing -> Nothing
Just right' -> Just (TREE
k' v' left right')
| k == k' -> Nothing
-- Nonsensical, but patterns without guards:
insert'' ::
key -> value -> Tree key value -> Maybe (Tree key
value)
insert'' _ _ EMPTY = Nothing
insert'' k v (TREE _ _ left right) = Just (TREE k v
left right)
======================================
Trac metadata
Trac field |
Value |
Version |
5.02 |
Type |
Bug |
TypeOfFailure |
OtherFailure |
Priority |
normal |
Resolution |
ResolvedDuplicate |
Component |
Compiler |
Test case |
|
Differential revisions |
|
BlockedBy |
|
Related |
|
Blocking |
|
CC |
|
Operating system |
|
Architecture |
|