String ++;带字符串和IO字符串的运算符
因为String ++;带字符串和IO字符串的运算符,string,haskell,io,String,Haskell,Io,因为getconsultion返回的值是IO字符串,所以不能简单地将其用于对未包装值进行操作的函数。如果答案回答了您的问题,请使用x第一次展开值,不要忘记将答案标记为已接受。如果仍然不清楚,请随时在评论中提出澄清问题,或用其他信息更新您的问题,而不是这样。 explandDol :: String -> String -> [String] -> IO String explandDol conclusion operators atoms = let (ys,zs)
getconsultion
返回的值是IO字符串
,所以不能简单地将其用于对未包装值进行操作的函数。如果答案回答了您的问题,请使用x第一次展开值,不要忘记将答案标记为已接受。如果仍然不清楚,请随时在评论中提出澄清问题,或用其他信息更新您的问题,而不是这样。
explandDol :: String -> String -> [String] -> IO String
explandDol conclusion operators atoms =
let (ys,zs) = splitAt (head (take 1 replacement)) conclusion in ys ++ getConclusion operators atoms ++ (tail zs)
where replacement = elemIndices '$' conclusion
getConclusion :: String -> [String] -> IO String
getConclusion operators atoms =
runRVar (choice [atom1 ++ " " ++ [operator] ++ " " ++ atom2 | atom1 <- atoms, atom2 <- atoms, operator <- operators,checkAtoms atom1 atom2]) StdRandom
/home/joe/Documents/haskell/LAG/main/main.hs: line 73, column 69:
Couldn't match expected type `IO String' with actual type `[Char]'
In the expression: ys ++ getConclusion operators atoms ++ (tail zs)
In the expression:
let (ys, zs) = splitAt (head (take 1 replacement)) conclusion
in ys ++ getConclusion operators atoms ++ (tail zs)
In an equation for `explandDol':
explandDol conclusion operators atoms
= let (ys, zs) = splitAt (head (take 1 replacement)) conclusion
in ys ++ getConclusion operators atoms ++ (tail zs)
where
replacement = elemIndices '$' conclusion
/home/joe/Documents/haskell/LAG/main/main.hs: line 73, column 75:
Couldn't match expected type `[Char]' with actual type `IO String'
In the return type of a call of `getConclusion'
In the first argument of `(++)', namely
`getConclusion operators atoms'
In the second argument of `(++)', namely
`getConclusion operators atoms ++ (tail zs)'
/home/joe/Documents/haskell/LAG/main/main.hs: line 73, column 75:
Warning: Redundant bracket
Found:
getConclusion operators atoms ++ (tail zs)
Why not:
getConclusion operators atoms ++ tail zs