Check if a list is sorted in Cloud Haskell

226 Views Asked by At

The main function I am using is

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

When I compile the program using ghc I get the following error.

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

Then I called remotable on 'sorted

remotable ['sorted]

and in the master function I take the mkClosure of it and also passed the input array as parameter to the sorted function.

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

I am not able to figure out the error. Any help is much appreciated guys.

0

There are 0 best solutions below