我偶然发现了一个存在于Haskell中的Eval monad和rparStrategy的问题。请考虑下面的代码: module Main where
import Control.Parallel.Strategies
main :: IO()
main = print . sum . inParallel2 $ [1..10000]
inParallel :: [Double] -
class Eq a where
(==), (/=) :: a -> a -> Bool
x /= y = not (x == y)
x == y = not (x /= y)
deriving instance Eq Bool
我认为它会产生 instance Eq Bool where
True == True = True
请原谅我下面可能滥用类别理论术语。如果我看起来有一半线索,我会判断自己非常成功。 我发现自己写了一系列的类来处理多个类型构造函数的产品。像这样: import Control.Applicative
-- | RWS monad.
newtype RWS r w s a = RWS {runRWS :: r -> s -> (a, s, w)}
-- | A class for unar
这是一个简单的函数。它需要一个输入Int并返回(可能为空)(Int, Int)对的列表,其中输入Int是任何对的立方元素的总和。 cubeDecomposition :: Int -> [(Int, Int)]
cubeDecomposition n = [(x, y) | x <- [1..m], y <- [x..m], x^3 + y^3 == n]
where m = trun