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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:54:17+00:00 2026-06-02T10:54:17+00:00

I would like to prettyprint a table-like data structure in Haskell (a list of

  • 0

I would like to prettyprint a table-like data structure in Haskell (a list of columns).

For example…

Table [
    StrCol "strings" ["a", "bc", "c"],
    IntCol "ints" [1, 30, -2],
    DblCol "doubles" [2.0, 4.5, -3.2]]

Should render something like…

strings ints doubles
    "a"    1     2.0
   "bc"   30     4.5
    "c"   -2    -3.2

Currently I have implemented this functionality in Text.PrettyPrint that comes with the most recent version of the Haskell Platform. Unfortunately the <+> operator orients multi-line documents “diagonally” from each other.

eg

(text "a" $+$ text "b") <+> (text "c" $+$ text "d")

renders as

a
b c
  d

rather than

a c
b d

As a result, I transpose the cells and merge them horizontally first, then vertically, but this results in the columns not being aligned.

In an older table pretty-printing question, augustss refers to adding some more code to have the columns automatically adapt to the widest entry.

I’m guessing that “sizedText” with the maximum length of each column would do this, except that this function doesn’t appear to be part of the Haskell Platform Text.PrettyPrint module (I think it’s in the closely related Text.Pretty package).

What’s the simplest non-hacky way of implementing this pretty-print functionality? This is a small part of my project so I’d like to avoid writing my own pretty-printing, and I’d prefer to avoid module dependencies if I can.

  • 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-02T10:54:24+00:00Added an answer on June 2, 2026 at 10:54 am

    http://hackage.haskell.org/package/boxes

    The boxes package

    A pretty-printing library for laying out text in two dimensions, using a simple box model….

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

Sidebar

Related Questions

Would like to declare data (Coord a) => Triangle a = Triangle{t0 :: a,
Would like to get step-by-step explanation of the following function in Haskell fibs =
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I've got a table cell that I would always like to be a particular
I would like to have a list of all the time zones available on
Would like some advice from this. I got a table where I want to
I am trying to lay out a table-like page with two columns. I want
I would like to store log4net config data in my application.config file. Based on
In Python, I'd like to write a function that would pretty-print its results to
Would like to be able to set colors of headings and such, different font

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.