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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:25:07+00:00 2026-06-17T20:25:07+00:00

GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim … linking … done.

  • 0
GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let fac 0 = 1
Prelude> let fac n = product [1..n]
Prelude> fac 100000
Segmentation fault: 11

does anyone have any idea why this would be happening?

fac 10000 works

running on OS X 10.8.2

hmm, so loading from file:

fac :: Integer -> Integer
fac 0 = 1
fac n = product [1..n]

runs.

also interesting is that using

fac :: Int -> Int

returns 0 for fac 100000. I would have expected (Just as JohnL) an error.

this site mentions:

  • More specifically, SegmentationFault is a way a type-unsafe language spells DoesNotUnderstand. In a typesafe statically-typed language like Haskell, you shouldn’t see segfaults.

is it something to do with the IO monad?

  • 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-17T20:25:08+00:00Added an answer on June 17, 2026 at 8:25 pm

    From a quick test, it appears to be caused by the fact that product isn’t strict, and the chain of thunks is causing the fault.

    In the prelude, product is defined as:

    product = foldl (*) 1
    

    If in ghci, you instead define it as:

    > :m + Data.List
    > let product = foldl' (*) 1
    > let fac n = product [1..n]
    

    Then it should work. I suspect when you specify the type signature, maybe some optimization is kicking in that isn’t present otherwise… but haven’t dug into it.

    Btw, you don’t need the let fac 0 = 1 line.

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

Sidebar

Related Questions

OS: MacOSX 10.7.1 GHC and Haskell-platform from brew. GHCi, version 7.0.4: http://www.haskell.org/ghc/ :? for
I'm using GHCi (version 6.12.3) to play a bit with Haskell. I recently read
Here's the error ghci throws when I try to run my program. >Loading package
Is there an official specification for the round function in Haskell? In GHCi version
Possible Duplicate: Haskell ranges and floats If I generate a list in ghci like
Today I am writing a small program in Haskell. I found that in ghci's
I recently installed (from the binary installers) GHC 6.12 and the Haskell Platform 2010.1.0.1
I'm trying to compile a recent version of GHC (say, 7.4 or 7.6) on
Is it possible to get Haskell Documentation from Terminal or from ghci? In Ruby
Suppose I've written a Haskell package that I'd like to release to Hackage. Suppose

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.