[ ghc-Bugs-485328 ] Check for exhaustive patterns continued

noreply@sourceforge.net noreply@sourceforge.net
Thu, 03 Jan 2002 05:58:25 -0800


Bugs item #485328, was opened at 2001-11-25 07:21
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=485328&group_id=8032

Category: Compiler
Group: 5.02
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Check for exhaustive patterns continued

Initial Comment:
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)

======================================



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=485328&group_id=8032