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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:28:52+00:00 2026-05-26T11:28:52+00:00

In ghci: λ> :t (pure 1) (pure 1) :: (Applicative f, Num a) =>

  • 0

In ghci:

λ> :t (pure 1)
(pure 1) :: (Applicative f, Num a) => f a
λ> show (pure 1)

<interactive>:1:1:
    No instance for (Show (f0 a0))
      arising from a use of `show'
    Possible fix: add an instance declaration for (Show (f0 a0))
    In the expression: show (pure 1)
    In an equation for `it': it = show (pure 1)
λ> pure 1
1

Does this mean that ghci execute Applicative and displays the result, just like IO?

Note that pure () and pure (+1) don’t print anything.

  • 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-26T11:28:53+00:00Added an answer on May 26, 2026 at 11:28 am

    You get the same behaviour if you use return instead of pure. To find out what to do, ghci must choose a type for the given expression. ghci’s defaulting rules are such that absent other constraints, it chooses IO for an Applicative or Monad instance. Thus it interprets pure 1 as an expression of type IO Integer. Expressions of type IO a entered at the prompt are executed and their results are printed, if 1. a has a Show instance and 2. a is not (). Thus entering pure 1 at the prompt results in

    v <- return (1 :: Integer)
    print v
    return v
    

    being executed (and the magic variable it bound to the returned v). For pure (), the special case applies since () is considered uninteresting, thus only return () is executed and it bound to (), for pure (+1), a function is returned, there’s no Show instance for functions in scope, so nothing is printed. However,

    Prelude Control.Applicative> :m +Text.Show.Functions
    Prelude Control.Applicative Text.Show.Functions> pure (+1)
    <function>
    it :: Integer -> Integer
    Prelude Control.Applicative Text.Show.Functions> it 3
    4
    it :: Integer
    

    with a Show instance for functions in scope, it gets printed (not that it’s informative), and the function can then be used (the latter is independent of a Show instance being in scope, of course).

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

Sidebar

Related Questions

Is it possible to get Haskell Documentation from Terminal or from ghci? In Ruby
When I use GHCi, I almost always end up importing Control.Applicative , Data.List ,
Possible Duplicate: Haskell ranges and floats If I generate a list in ghci like
ghci> 4 == 3.9999999999999999 True ghci> 10.2^2 == 104.04 False Why the 2nd expression
Whenever I close OpenGL window it makes ghci console from which the app was
I get an error message from GHCi about a duplicate definition for symbol __module_registered,
To strip the last item from a list in GHCi I can reverse the
I am wondering if it is possible to keep assigned values in ghci when
The :browse , :info and :type GHCi commands are very convenient. Is it possible
Possible Duplicate: Finite comprehension of an infinite list I can't understand why ghci can't

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.