Opened 14 years ago

Closed 14 years ago

Last modified 46 years ago

#30 closed bug (Duplicate)

Check for exhaustive patterns continued

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 5.02
Keywords: Cc:
Operating System: Architecture:
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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)

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


Change History (1)

comment:1 Changed 14 years ago by sewardj

  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.