如何为Haskell安装“ Data.List.Split”模块?

时间:2020-06-13 09:35:55

标签: haskell module installation cabal

从昨天开始,我一直在尝试导入'Data.List.Split'模块。我在堆栈溢出周围四处寻找类似的问题,但找不到针对我这个基本问题的最终解决方案。

这就是我在文本编辑器中写的内容(不包括注释)。

import Data.List
import Data.Char
import System.IO

data Cell = Fixed Int | Possible [Int] deriving (Show, Eq)

type Grid = [Row]

readGrid :: String -> Maybe Grid
readGrid s
  | length s == 81 = traverse (traverse readCell) . Data.List.Split.chunksOf 9 $ s
  | otherwise      = Nothing
  where
     readCell '.' = Just $ Possible [1...9]
     readCell c
       | Data.Char.isDigit c && c > '0' = Just . Fixed . Data.Char.digitToInt $ c
       | otherwise = Nothing

这是我在命令行中写的。

cabal update
cabal install --lib split
cd 'C:\Users\Username\Haskell Sudoku Solver'
ghci
:l Sudoku-Solver

这是出现的错误消息

Sudoku-Solver.hs:53:53: error:
    Not in scope: `Data.List.Split.chunksOf'
    No module named `Data.List.Split' is imported.
   |
53 |   | length s == 81 = traverse (traverse readCell) . Data.List.Split.chunksOf 9 $ s
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^

我猜想'cabal install --lib split'将解决问题,但错误仍然出现。很抱歉,这是初学者级别的问题。

0 个答案:

没有答案