小编Jua*_*nto的帖子

Haskell - 如何在IO函数中使用纯函数?

如何在IO函数中使用纯函数?: - /

例如:我正在读取一个文件(IO函数),我想通过使用具有引用透明性的纯函数来解析其上下文,一个字符串.

似乎这样的世界,纯函数和IO函数是分开的.我怎么可能桥接他们?

io haskell referential-transparency

5
推荐指数
2
解决办法
3041
查看次数

在Haskell中编写AI Solver时出现模糊类型变量

我正在Haskell编写一个AI General Problem Solver,用于Coursera的AI Planning课程,ghci抱怨一个模糊的类型变量.这是Haskell代码和我得到的错误:

-- Solver.hs
{-# LANGUAGE GADTs,FlexibleInstances,UndecidableInstances,ScopedTypeVariables,TypeFamilies,MultiParamTypeClasses #-}

module Solver
(Solver,State,Transition)
where

class (Show t,Eq t) => Transition t where
 transition :: State s => s -> t -> s

class (Show s,Eq s) => State s where
 getPossibleTransitions :: Transition t => s -> [t]
 isStateValid :: s -> Bool
 isGoalState :: s -> Bool

class Solver s t where
 getPossibleNextStates :: s -> [s]
 isStateVisited :: [s] -> s -> Bool
 getNextFringeStates :: [s] -> …
Run Code Online (Sandbox Code Playgroud)

haskell typeclass ghci

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

Haskell和Regex - 为什么我的函数不能消除RedundantSpaces的工作?

Haskell和Regex - 为什么我的函数不能消除RedundantSpaces的工作?

import Text.Regex
eliminateRedundantSpaces text =
 subRegex (mkRegex "\\s+") text " "
Run Code Online (Sandbox Code Playgroud)

regex haskell

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

标签 统计

haskell ×3

ghci ×1

io ×1

referential-transparency ×1

regex ×1

typeclass ×1