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

The Archive Base Latest Questions

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

In the Functors, Applicative Functors and Monoids chapter of Learn You A Haskell, Miran

  • 0

In the “Functors, Applicative Functors and Monoids” chapter of Learn You A Haskell, Miran does the following:

ghci> (pure 3) "blah"
3

I however get this:

ghci> (pure 3) "blah"
<interactive>:1:2:
    No instance for (Functor ((->) [Char]))
      arising from a use of `pure'
    Possible fix:
      add an instance declaration for (Functor ((->) [Char]))
    In the expression: (pure 3) "blah"
    In an equation for `it': it = (pure 3) "blah"

I am not sure what happen. All the examples have worked correctly until now. I must not have imported something, but I don’t know what.

Here is my version information:

$ ghci -v
GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
Glasgow Haskell Compiler, Version 7.0.4, for Haskell 98, stage 2 booted by GHC version 6.12.3

My ~/.ghc/ghci.conf looks like this:

{-# LANGUAGE Arrows #-}

:set prompt "[32;1m%s[0m\n> "

import Control.Arrow
import Control.Monad (when, forever, forM, liftM)
import Control.Applicative
-- import Control.Applicative (ZipList (..), (<$>), (<*>), pure)
import Control.Exception (IOException (..), catch)
import qualified Data.ByteString as ByteString (pack, unpack)
import qualified Data.ByteString.Lazy as LazyByteString (cons, cons', empty, fromChunks, pack, readFile, unpack, writeFile)
import Data.Char (chr, ord, toUpper, toLower, isDigit)
import Data.Function (fix, on)
import Data.Functor
import Data.List (find, genericLength, intercalate, intersperse, nub, tails)
import Data.Map (Map (..))
import qualified Data.Map as Map (fromList, lookup)
import Data.Monoid (mempty, mappend, mconcat)
import Data.Tuple (fst, snd, curry, uncurry, swap)
import System.Console.ANSI (setCursorPosition, clearScreen)
import System.Directory (renameFile, doesFileExist)
import System.Environment (getArgs, getProgName)
import System.IO (IOMode (..), stdout, openFile, withFile, hGetContents, hClose, openTempFile, hPutStr, hFlush)
import System.IO.Error (isDoesNotExistError)
import System.Random (StdGen (..), RandomGen (..), Random (..), getStdGen, mkStdGen, newStdGen, random, randomR, randomRIO, randoms)
import Text.Printf (PrintfArg (..), printf)
  • 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-26T04:40:23+00:00Added an answer on May 26, 2026 at 4:40 am

    You’re missing Control.Monad.Instances. Not sure why it’s defined there, but I’ve run into this before as well.

    GHCi, version 7.0.4: 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 Control.Applicative> (pure 3) "blah"
    
    <interactive>:1:2:
        No instance for (Functor ((->) [Char]))
          arising from a use of `pure'
        Possible fix:
          add an instance declaration for (Functor ((->) [Char]))
        In the expression: (pure 3) "blah"
        In an equation for `it': it = (pure 3) "blah"
    Prelude Control.Applicative> import Control.Monad.Instances 
    Prelude Control.Applicative Control.Monad.Instances> (pure 3) "blah"
    3
    

    Also, after looking at the chapter in LYAH, the author does define the instance above the example, but it’s not obvious this is already defined elsewhere.

    Update

    The error wasn’t because ghci forgot how to apply functors, rather the Functor instance Functor ((->) [Char]) was not yet defined in your environment.

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

Sidebar

Related Questions

Learn You a Haskell has an example about functors. I can read LYAH, and
While using applicative functors in Haskell I've often run into situations where I end
This question arose while reading the new chapter in the excellent Learn You a
I could write myself a helper class that does this when given a functor,
Based on chapter 5 (Generalized Functors) from the book Modern C++ Design, I'm trying
I have a List[Option[Int]] and want to sum over it using applicative functors. From
Im trying to understand what a functor is, i found this tutorial/example: http://en.wikibooks.org/wiki/Haskell/Solutions/Applicative_Functors data
I've found some good examples of functors on SO like this one, and all
I've been reading about applicative functors, notably in the Functional Pearl by McBride and
The STL functors are implemented like this: template<class T> struct less{ bool operator()(T const&

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.