在「仿函數,應用型函子幺」瞭解你的Haskell的章,米朗執行以下操作:GHC 7.0.4似乎已經忘記了如何申請函子
ghci> (pure 3) "blah"
3
然而,我得到這個:
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"
我不確定會發生什麼。直到現在,所有示例都正常運行。我不能輸入一些東西,但我不知道是什麼。
這裏是我的版本信息:
$ 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
我的〜/ .ghc/ghci.conf看起來是這樣的:
{-# 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)
適合我... – Landei
什麼版本的ghci是那個? –
適用於使用「The Glorious Glasgow Haskell編譯系統,版本7.0.3」,從'Control.Applicative'輸入'pure'' –