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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:11:41+00:00 2026-05-20T23:11:41+00:00

I am very new to Haskell. Today when I reading the book and practice

  • 0

I am very new to Haskell.
Today when I reading the book and practice it’s example I got an error.
Here is the source code Nullable.hs in Chapter 3 page 57.

import Prelude hiding (Maybe)

{-- snippet Nullable --}
data Maybe a = Just a
             | Nothing
{-- /snippet Nullable --}

{-- snippet wrappedTypes --}
someBool = Just True

someString = Just "something"
{-- /snippet wrappedTypes --}


{-- snippet parens --}
wrapped = Just (Just "wrapped")
{-- /snippet parens --}

when I type ghci Nullable.hs
got:

GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
[1 of 1] Compiling Main             ( Downloads/examples/ch03/Nullable.hs, interpreted )

Downloads/examples/ch03/Nullable.hs:9:11:
    Ambiguous occurrence `Just'
    It could refer to either `Main.Just', defined at Downloads/examples/ch03/Nullable.hs:4:15
                          or `Prelude.Just', imported from Prelude at Downloads/examples/ch03/Nullable.hs:1:0-28

Downloads/examples/ch03/Nullable.hs:11:13:
    Ambiguous occurrence `Just'
    It could refer to either `Main.Just', defined at Downloads/examples/ch03/Nullable.hs:4:15
                          or `Prelude.Just', imported from Prelude at Downloads/examples/ch03/Nullable.hs:1:0-28

Downloads/examples/ch03/Nullable.hs:16:10:
    Ambiguous occurrence `Just'
    It could refer to either `Main.Just', defined at Downloads/examples/ch03/Nullable.hs:4:15
                          or `Prelude.Just', imported from Prelude at Downloads/examples/ch03/Nullable.hs:1:0-28

Downloads/examples/ch03/Nullable.hs:16:16:
    Ambiguous occurrence `Just'
    It could refer to either `Main.Just', defined at Downloads/examples/ch03/Nullable.hs:4:15
                          or `Prelude.Just', imported from Prelude at Downloads/examples/ch03/Nullable.hs:1:0-28
Failed, modules loaded: none.
Prelude> 

I thought this problem caused by scope so I add a prefix to “Just” like this someBool = Main.Just True and try again got:

[1 of 1] Compiling Main             ( nu.hs, interpreted )
Ok, modules loaded: Main.
*Main> Just 1

<interactive>:1:0:
    No instance for (Show (Maybe t))
      arising from a use of `print' at <interactive>:1:0-5
    Possible fix: add an instance declaration for (Show (Maybe t))
    In a stmt of an interactive GHCi command: print it

Now I can confirm that it is not only caused by scope error. But I can not handle it…

What would be a way to do this?
Any suggestion will be appreciate.

  • 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-20T23:11:41+00:00Added an answer on May 20, 2026 at 11:11 pm

    No, the original error was caused by a scope error, and so when you qualified it explicitly you fixed one error but introduced another.

    You can fix the other error by adding a deriving (Show) line to your original code:

    data Maybe a = Just a
             | Nothing
        deriving (Show)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new in haskell, i wrote the code for item details and
New to Haskell so sorry if this is very basic This example is taken
Very new mobile developer here... I am trying to retrieve a list of tweets
I am from OO background and very new to Haskell. In order to print
Sorry if the question is very elementary, I am still very new to Haskell.
Very new to both JSON and jQuery , but here is what I am
I'm brand new to Haskell and have very little idea what I'm doing. I've
I'm very new to Haskell, and I have a simple question. What function can
I am very new to Haskell. Could someone please explain why defining a list
Very new to javascript here folks, so forgive the newbie question. I want to

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.