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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:49+00:00 2026-05-27T07:17:49+00:00

In my homework I have to define the logic operators as follows: Using this

  • 0

In my homework I have to define the logic operators as follows:
Using this data structure:

data MyBool = Cierto|Falso deriving (Show,Eq) -- Cierto = True and Falso = False
data PQR = A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z deriving (Show,Eq)
data Formula = VarProp PQR 
             |Neg Formula -- logic not
             |Formula :|: Formula -- logic or
             |Formula :&: Formula -- logic and... etc
             |Formula :->: Formula
             |Formula :<->: Formula deriving (Show,Eq)

And I have to define functions that tell me if a given formula is True or False, so for example if I write (Cierto :&: Falso) the answer has to be: Falso.

According to my teacher the function has to be called in this case :&: and has to receive MyBool types so I tried to implemented like this:

infixr 3 :&:
(:&:) :: MyBool -> MyBool -> MyBool
Cierto :&: x = x
Falso :&: x = Falso

but when I try to load it it says:

Invalid type signature

I don’t know what I doing wrong here.

  • 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-27T07:17:50+00:00Added an answer on May 27, 2026 at 7:17 am

    Your professor is forcing you to create an Abstract Syntax Tree(AST) for boolean operators. if you have not heard the words “Abstract Syntax Tree” prior to this, it is time to ask someone what the heck is going on.

    What you in fact want to do is write a function (called say eval) with the type Formula -> Formula. In looking at the definition, I also believe you have left a line out of data Formula that should be something like VarLiteral MyBool. It looks like you AST is a way of writing programs which operate on MyBool‘s and supports the typical boolean operations along with :->: assign (?).

    I’ve written a few AST evaluators in Haskell (though nothing this corny 🙂 ) and it feels like there are a few pieces missing in your question. My best advice for you, given what I have in front of me, is to say that this assignment is one level more abstract than you think it is.

    Best of Luck

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

Sidebar

Related Questions

I have in my homework some question about data structure: I have elements which
For my homework I have to test for several large matrices using this Conjugate
I'm using Notepad++ and WinGHCi to do some homework and I have to define
(this is indirectly a part of a much larger homework assignment) I have something
Okay this is a homework question, and I just don't have a clue how
(Before anyone asks, this is not homework.) I have a set of workers with
I have this homework to school - I completed it sent it and got
I have this object parsed using SimpleXML: SimpleXMLElement Object ( [contact] => SimpleXMLElement Object
I have this insane homework where I have to create an expression to validate
I have a graph like this: As part of a homework assignment I want

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.