runtime error in Haskell

My program is searching in list of tuples I wrote it as the following

import List
data BookInfo = Book Int String [String]
  deriving(Show)

enter :: Int->String->[String]->BookInfo
enter id name subject=Book id name subject
bookId   (Book id _     _  ) = id

index :: BookInfo -> Int
index (Book id name subject) =  bookId  (Book id name subject) 

arrayentering ::BookInfo->[BookInfo]->[BookInfo]
arrayentering (Book id name subject) [] =[(Book id name subject)]
arrayentering (Book  _  "     " ["    "]) [] =[]
arrayentering (Book id name subject) [(Book it namr suject)]=                         
              (Book id name subject):[(Book it name suject)]
toList::[BookInfo]->[Int]
toList [(Book id name subject) ]=   map index [ (Book id name subject)]

bubbleSort::(Ord t) => [t]->[t]
bubbleSort[x,y,z,xs]=
                if x<y then x : [y,z,xs]
                       else y : [x,z,xs]

superBubble::(Ord t) => [[t]]->[[t]]
superBubble a=map bubbleSort a

combining::[BookInfo]->[[Int]]
combining [(Book id name subject)]=superBubble [toList [(Book id name subject)]]

and clean it from any syntax error but after i try to enter to a list of tuple to combining() it gve me runtime error say

Exception:Not Exhaustive pattern in function Main.combining

What does this mean?

Please, give me only instructions. If possible, I would like to fix it by my self.

Answers


The pattern in the function definition

combining [(Book id name subject)]=superBubble [toList [(Book id name subject)]]

matches only lists with exactly one element. You have a similar problem in bubbleSort, where

bubbleSort[x,y,z,xs]=

matches only lists with exactly four elements and elsewhere.

I haven't figured out how you intend it to work, perhaps using a variable pattern (that matches all arguments)

combining books = superBubble (toList books)

would be appropriate?


I suspect

arrayentering ::BookInfo->[BookInfo]->[BookInfo]
arrayentering (Book id name subject) [] =[(Book id name subject)]
arrayentering (Book  _  "     " ["    "]) [] =[]
arrayentering (Book id name subject) [(Book it namr suject)]=                         
              (Book id name subject):[(Book it name suject)]

should really be

arrayentering book bookList
    | empty book = bookList
    | otherwise  = book : bookList
      where
        empty (Book _ name subject) = all isSpace name && all (all isSpace) subject

(empty may be wrong).

And toList should probably be just map index.


Need Your Help

Symfony2 HTML5 integer input and validator

html5 validation symfony integer

I'm using symfony2 and I have an input field, I need people to put numbers in it, but I'm having trouble with validation.

How to show the “Previous/Next/Done” bar with a UITextView

iphone keyboard

i've seen a "Previous/Next/Done" bar above the keyboard when entering text in a webview on an iPhone. i want to use this built in bar in an app that i'm making in conjunction with a UITextView. i h...