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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:33:58+00:00 2026-06-07T12:33:58+00:00

I was wondering what the preferred method is to convert lazy text into a

  • 0

I was wondering what the preferred method is to convert lazy text into a list of strict texts split up by line endings. I came up with something like the following, but am not sure that I’m guaranteed that each strict text element will be a complete line (or if there are other problems with it):

import qualified Data.Text.Lazy as LT

readLines filePath = do
    contents <- Data.Text.Lazy.IO.readFile filePath
    let lines = concat (map LT.toChunks (LT.lines contents))
    return lines
  • 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-07T12:34:03+00:00Added an answer on June 7, 2026 at 12:34 pm
    readLines filePath = do
        contents <- Data.Text.Lazy.IO.readFile filePath
        let lines = concat (map LT.toChunks (LT.lines contents))
        return lines
    

    doesn’t guarantee that each strict chunk is a complete line. In fact, every time a chunk boundary of the lazy Text does not coincide with a line boundary, you get a line having part in at least two strict chunks.

    readLines filePath = do
        contents <- Data.Text.Lazy.IO.readFile filePath
        let lines = map (T.concat . LT.toChunks) (LT.lines contents)
        return lines
    

    however, concatenates each line into one strict chunk. Doing the concatenation may however be slower than working with each line as a list of strict chunks resp. a lazy Text.

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

Sidebar

Related Questions

Just wondering if there's a preferred method or Best Practice for storing Updated By
I was wondering what is the preferred method of licensing a web site? I
Im currently building something with Neo4j and Neography and were wondering what is preferred:
When using UiBinder what is the preferred method of creating a simple layout like
I was wondering if it were a good idea to use an initializer list
Specifically im wondering if in java (preferred) or perl is it possible to enter
I am wondering what the best (free preferred) sql query designers tools for Windows
I am wondering what the prefered method of validating user input in asp.net using
I am wondering what would be the best/preferred way to write a scanning app
I'm wondering about the preferred way to import packages in a Python application. 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.