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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:54:11+00:00 2026-05-22T16:54:11+00:00

I have CSV data (inherited – no choice here) which I need to use

  • 0

I have CSV data (inherited – no choice here) which I need to use to create data type instances in Haskell. parsing CSV is no problem – tutorials and APIs abound.

Here’s what ‘show’ generates for my simplified trimmed-down test-case:

JField {fname = "cardNo", ftype = "str"} (string representation)

I am able to do a read to convert this string into a JField data record. My CSV data is just the values of the fields, so the CSV row corresponding to JField above is:

cardNo, str

and I am reading these in as List of string [“cardNo”, “str”]

So – it’s easy enough to brute-force the exact format of “string representation” (but writing Java or python-style string-formatting in Haskell isn’t my goal here).

I thought of doing something like this (the first List is static, and the second list would be read file CSV) :

let stp1 = zip ["fname = ", "ftype ="] ["cardNo", "str"]

resulting in

[("fname = ","cardNo"),("ftype =","str")]

and then concatenating the tuples – either explicitly with ++ or in some more clever way yet to be determined.

This is my first simple piece of code outside of tutorials, so I’d like to know if this seems a reasonably Haskellian way of doing this, or what clearly better ways there are to build just this piece:
fname = “cardNo”, ftype = “str”

Not expecting solutions (this is not homework, it’s a learning exercise), but rather critique or guidelines for better ways to do this. Brute-forcing it would be easy but would defeat my objective, which is to learn

  • 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-22T16:54:12+00:00Added an answer on May 22, 2026 at 4:54 pm

    I might be way off, but wouldn’t a map be better here? I guess I’m assuming that you read the file in with each row as a [String] i.e.

    field11, field12
    field21, field22
    

    etc.

    You could write

    map (\[x,y] -> JField {fname = x, ftype = y}) data
    

    where data is your input. I think that would do it.

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

Sidebar

Related Questions

I have a datagrid which is populated with CSV data when the user drag/drops
I have .zip file which contain csv data. I am reading .zip file using
I have csv file having some address data mostly in Finnish language. I need
I have inherited some code that uses regular expressions to parse CSV formatted data.
I have a csv data set containing a date field which my may or
I have a NSString *csvData which contains the csv data and the format is
I have CSV data loaded into a multidimensional array. In this way each row
I have a CSV data file with rows that may have lots of columns
I have a number of images and a CSV data file that I want
I have an xml schema and csv data to generate corresponding xml files. I

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.