检查列表是否在Cloud Haskell中排序

时间:2018-04-08 18:32:05

标签: sorting haskell functional-programming cloud-haskell

我使用的主要功能是

sorted :: [Integer] -> Process Bool
sorted a = same $ map (>0) $ filter (/=0) $ zipWith (-) a (tail a)
    where
          same (x:xs) = and $ map (==x) xs

当我使用ghc编译程序时,我收到以下错误。

shreyas@shreyas-Inspiron-13-7368:~/Desktop/haskell/my-project/src$ ghc Main.hs[1 of 1] Compiling Main             ( Main.hs, Main.o )
Main.hs:9:12: error:
    • Couldn't match expected type ‘Process Bool’
                  with actual type ‘Bool’
    • In the expression:
        same $ map (> 0) $ filter (/= 0) $ zipWith (-) a (tail a)
      In an equation for ‘sorted’:
          sorted a
            = same $ map (> 0) $ filter (/= 0) $ zipWith (-) a (tail a)
            where
                same (x : xs) = and $ map (== x) xs

然后我在“排序

”上调用了遥控器
remotable ['sorted]

并在master函数中我接受它的mkClosure并将输入数组作为参数传递给sorted函数。

master :: [NodeId] -> Process ()
master [] = liftIO $ putStrLn "no slaves"
master (slave:_) = do
sortedTrio <- call $(functionTDict 'sorted) slave ($(mkClosure 'sorted)([1,2,3]::[Integer]))
liftIO $ print sortedTrio

我无法弄清楚错误。任何帮助都非常感谢。

0 个答案:

没有答案