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 7890419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:20:58+00:00 2026-06-03T06:20:58+00:00

I wrote a program with haskell but I got errors from ghci here is

  • 0

I wrote a program with haskell but I got errors from ghci

here is the source codes,I construct it, and if I have

p1 :: Prop
p1 = And (Var 'A') (Not (Var 'A'))

It will show A && ~A so that is the source codes

import Data.List
import Data.Char
data Prop = Const Bool | 
        Var Char | 
        Not Prop | 
        And Prop Prop | 
        Or Prop Prop | 
        Imply Prop Prop
        deriving Eq
instance Show Prop where
  show (Var Char) = show Char
  show (Not Prop) = "(~" ++ show Prop ++ ")"
  show (And Prop Prop) = "(" ++ show Prop ++ "&&" ++ show Prop ++ ")"
  show (Or Prop Prop) = "(" ++ show Prop "||" ++ show Prop ++ ")"
  show (Imply Prop Prop) = "(" ++ show Prop "=>" show Prop ++ ")"

And I got two main errors from ghci…

Not in scope: data constructor `Char'
Not in scope: data constructor `Prop'

I am a beginner with haskell,thankyou very much.

  • 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-06-03T06:20:59+00:00Added an answer on June 3, 2026 at 6:20 am

    Value names that start with an uppercase letter are reserved for constructors, like Var, True, False, etc. Variables must start with a lowercase letter.

    Additionally, you can’t use the same name for two different variables. How would Haskell know which one you meant each time you used them? You can’t simply use the definition of a constructor as a pattern in a function; you need to give a separate name to each field.

    So, instead of Var Char, write Var name; instead of Imply Prop Prop, write Imply p q (or Imply prop1 prop2), and so on.

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

Sidebar

Related Questions

I have a problem. I wrote a big Haskell program, and it always works
I wrote a little Haskell program to find the area of a triangle, primarily
I need to write a haskell program that retrieves a file from command line
I am solving some problems of Project Euler in Haskell. I wrote a program
I've got a Haskell program that needs to execute a separate (third party) binary;
At one point I wrote a packet capture program in haskell and it used
If using Haskell as a library being called from my C program, what is
I wrote a program which includes writing and reading from database. When I run
I wrote a program for retrieving mail from POP3 servers. One of its users
I am new at haskell, I have to write a program context-aware,so I thought

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.