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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:22:44+00:00 2026-05-26T19:22:44+00:00

Suppose I have: import qualified Data.ByteString.Lazy as L bs1 :: L.ByteString bs2 :: L.ByteString

  • 0

Suppose I have:

import qualified Data.ByteString.Lazy as L
bs1 :: L.ByteString
bs2 :: L.ByteString

Is L.append bs1 bs2 also lazy in that this will not cause me to consume all of bs1 immediately? Similarly with L.concat and unlike L.length which I understand will cause it to consume the entire bytestring because it needs to count all the bytes.

  • 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-26T19:22:44+00:00Added an answer on May 26, 2026 at 7:22 pm

    A simple way of determining how lazy a function is, is to pass it partially defined values. For example, let’s define a lazy bytestring of one chunk followed by an undefined tail.

    *Main> let bs1 = L.fromChunks $ B.pack [102, 111, 111] : undefined
    *Main> bs1
    Chunk "foo" *** Exception: Prelude.undefined
    

    As you can see, attempting to print it throws an exception after the first chunk. Now, let’s define another lazy ByteString and try to append them.

    *Main> let bs2 = L.pack [98, 97, 114]
    *Main> L.append bs1 bs2
    Chunk "foo" *** Exception: Prelude.undefined
    

    L.append was able to produce the first chunk of the resulting lazy ByteString. This means that it only had to look at the first chunk of bs1 to produce the first chunk of the result, i.e. it’s as lazy as you would expect it to be.

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

Sidebar

Related Questions

Suppose I have this Python code: from itertools import count, tee original = count()
I have to create a simple Magento 1.6.x import agent that suppose to create/update
Suppose I have this: from threading import local tl = local() At various points,
Suppose you have these modules: module1.py import module2 def a(): module1.b() def c(): print
Suppose I have a recarray such as the following: import numpy as np #
Suppose I have an Anti-XML object, e.g.: import com.codecommit.antixml._ val child = <child attr=val>...</child>.convert
Suppose I have a pure virtual method in the base interface that returns to
Suppose I have a static method of my class that returns an object of
Suppose I have a class Baz that inherits from classes Foo and Bar ,
Suppose I have the following Event model: from django.db import models import datetime class

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.