Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:36:46+00:00 2026-05-29T07:36:46+00:00

Im doing a small system from Haskell and im getting two errors called Last

  • 0

Im doing a small system from Haskell and im getting two errors called
“Last generator in do {…} must be an expression” and
“Type error in explicitly typed binding
Term : (fname,lname,cnic)
Type : (a,b,c)
Does not match : Database
“

im new to haskell so plz help me out.

-------Data types-------

type FirstName = String
type LastName = String
type CustomerNIC = String
type Database = ( FirstName , LastName , CustomerNIC ) 
--type Details = [Database]

------Data base---------


exampleBase :: [Database]
exampleBase = [ ( "Kevin" , "Desilva" , "8929323V" ),( "Nimal" , "Perera" , "89120323V" ) ]

-------Main Menu-----------------------------
getInt :: IO Int
getInt = do line <- getline 
        return (read line :: Int)

selectsearch ::IO()
selectsearch = do 
                    putStr"\n\n\t 1.Search by NIC:"
                    putStr"\n\n\t 2.Search by First Name:"
                    putStr"\n\n\t Your Chocie:"
                    input<-getInt
                    subsearch input

subsearch :: Int->IO()
subsearch x = do
                if(x=1) then do
                                putStr"\n\t Enter NIC:"
                                cnic <- getLine
                                subsearch
                else if (x=2) then do
                                putStr"\n\t Enter First Name:"
                                cnic <- getLine
                                subsearch
                else if (x=3) then putStr "\n ERROR"
                                selectsearch

            else MainMenu

------- Search ------------

getfName :: Database -> FirstName 
getfName ( fname , lname , cnic ) = fname

searchByFirstName :: Database -> FirstName -> Database
searchByFirstName (a:ax) fname 
                    | fname == getfName a = a 
                    | length ax == 0 && getfName a/= fname = ("No Data","",0)
                    | otherwise = searchByFirstName ax fname  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:36:47+00:00Added an answer on May 29, 2026 at 7:36 am

    A few points:

    • There are weird indentation things throughout. Make sure you’re using spaces and not tabs.

    • In subsearch, you often have cnic <- getLine (when you probably want getInt), but then not use that in the recursive call.

    • In your if statements, you should have x == 1, etc. rather than x = 1. Also consider using a case statement or guards rather than nested if-then-else.

    • You’re missing a “do” in your x == 3 case.

    • getInt is identical to readLn.

    • Your searchByFirstName function could be written better.

    • A Database is made of three String fields, but your error case in searchByFirstName returns a value of type (String, String, Int).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When doing small icons, header graphics and the like for websites, is it better
I am doing small Silverlight app which will allow users to Create orders. I
Sometimes, when we're doing small changes to our web apps, e.g. bug fixes, we
While doing some small regex task I came upon this problem. I have a
i am doing one small application , wheich have login functionality, in the user
I am doing this small exercise. declare @No decimal(38,5); set @No=12345678910111213.14151; select @No*1000/1000,@No/1000*1000,@No; Results
I am doing simple forms authentication for a small ASP.NET (3.5, C#) application and
I have a small project I am doing in Python using web.py. It's a
I have a small- to medium-size project that I am doing for my software
I am doing a file server migration and I'm writing a small C# app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.