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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:59:51+00:00 2026-05-27T02:59:51+00:00

I started Intelligent System studies at a university and our first language is Haskell.

  • 0

I started Intelligent System studies at a university and our first language is Haskell. I must admit that I am not really familiar with it so far. Part of this week’s task is to develop an algebraic datatype Expr a which represents the basic arithmetic operations (+,-,*,/).

The solution IMO should be:

module Expression where

data Expr a
  = Number a
  | Var
  | Sum (Expr a) (Expr a)
  | Prod (Expr a) (Expr a)
  | Div (Expr a) (Expr a)
  | Pot (Expr a) a
  deriving (Show)

Okay so far. The task is to implement a pretty-instance for our function now. i.e.:

from

Plus (Pot (Var 2)) (Num 3)

to

x^2 + 3

So, I had no idea what "pretty" means. After searching the internet I found out that "pretty" only means to rewrite the output in a human readable form. Is this correct? If it is, what does it mean to my function? Do I have to replace the show function with a pretty function? I don’t really know where to start.

I read several similar questions here but didn’t get the point there. I would really be happy if someone could give me some hints, advice, solutions or whatever!

  • 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-27T02:59:52+00:00Added an answer on May 27, 2026 at 2:59 am

    Yes, that’s what pretty print means.

    Basically, you just need a function that converts an Expr a into a String:

    myPrettyPrint :: Expr a -> String
    

    Call it whatever you want, and don’t try to replace show.

    In order to implement this function, you’ll probably want to learn about pattern matching.

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

Sidebar

Related Questions

Just started getting a bunch of errors on our C# .Net app that seemed
Started getting a ClassCastException in a widget I've been working on that I'm not
Started with this question: OpenID. How do you logout OK. So OpenID does not
I started programming C# applications when the 1.0 framework was first released. I worked
I started dabbling in groovy yesterday. There's an example on the groovy website that
I'm getting started with building a Business Intelligence system using MS technologies. I don't
Started to learn some shell scripting. I have a perl script that runs on
Started to learn haskell today for school and I run into a problem with
Started researching Transfer ORM recently and find it pretty cool. Today I've noticed that
Started using PDO prepared statements not too long ago, and, as i understand, it

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.