Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,398
    • Issues 5,398
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 586
    • Merge requests 586
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #30
Closed
Open
Issue created Nov 25, 2001 by nobody@trac-nobody

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking