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

  • Home
  • SEARCH
  • 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 8924063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:18:23+00:00 2026-06-15T07:18:23+00:00

This is an excerpt from homework. Prog This datatype should have only one constructor

  • 0

This is an excerpt from homework. “Prog
This datatype should have only one constructor and be used for representing programs of
the form:

read vin1 ; read vin2 ; < some statements > write vout2 ;

This constructor, which can also be named Prog, takes a string for the names of the two
input and one output variable.”

Define expProg to be of type Prog and to be the abstract syntax representation of the
program on the left above.
This should be done as follows:

expProg = Prog "x" "y" <some statements> "z"

I am new to Haskell and am confused by this.

I made a constructor like this. However this doesnt seem right.

data Prog = Prog String String String 
  deriving (Show,Eq)

Could anyone explain whats going on here? I do not understand how to make this constructor.
Here is the data type i made for statements:

 data Stmt = Assing String Expr
      | WhileLoop Expr Stmt
      | Ifthen Expr Stmt
      | IfthenElse Expr Stmt Stmt
      | Composition [Stmt]
  • 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-15T07:18:24+00:00Added an answer on June 15, 2026 at 7:18 am

    You said you needed to include “some statements” in the constructor as well. Currently, you only have room for the two input variables and the output variable. Simply add another field for the statements, for example like this:

    data Prog = Prog String String Stmt String
    --                                  ^ output variable
    --                             ^ some statements
    --                       ^ input variable 2
    --               ^ input variable 1
    

    Now you can use it like so:

    expProg = Prog "x" "y" (Composition [Assing "x" (...some expression...),
                                         Assing "z" (...some expression...)])  "z"
    

    (Note that it’s actually spelled Assign, not Assing)

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

Sidebar

Related Questions

This is an excerpt from the instructions of my homework for my operating systems
Greetings! I must be seeing things. Look at this excerpt from the iPhone OS
This is an excerpt of some c++ code, that i'll have to explain in
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
I know that I am missing something simple here. I have got this homework
I'm reading up on developing GWT apps and read an excerpt from this page:
This is an excerpt from a source file of wxPython: Create the output window
This is an excerpt from AnyEvent::Intro # register a read watcher my $read_watcher; $read_watcher
As you can see from this excerpt, there is a ! before the git
Here's an excerpt from java.text.CharacterIterator documentation: This interface defines a protocol for bidirectional iteration

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.