小编Max*_*Max的帖子

如何读取(和解析)文件,然后附加到同一文件而不会出现异常?

我试图在Haskell中正确读取文件,但我似乎得到了这个错误.

***例外:neo.txt:openFile:资源忙(文件被锁定)这是我的代码.

import Data.Char
import Prelude
import Data.List
import Text.Printf
import Data.Tuple
import Data.Ord
import Control.Monad
import Control.Applicative((<*))

import Text.Parsec
    ( Parsec, ParseError, parse        -- Types and parser
    , between, noneOf, sepBy, many1    -- Combinators
    , char, spaces, digit, newline     -- Simple parsers
    )
Run Code Online (Sandbox Code Playgroud)

这些是电影领域.

type Title = String
type Director = String
type Year = Int
type UserRatings = (String,Int) 
type Film = (Title, Director, Year , [UserRatings])
type Period = (Year, Year)
type Database = [Film]
Run Code Online (Sandbox Code Playgroud)

这是所有类型的解析,以便从文件中正确读取

-- …
Run Code Online (Sandbox Code Playgroud)

haskell exception file locked

3
推荐指数
1
解决办法
591
查看次数

标签 统计

exception ×1

file ×1

haskell ×1

locked ×1