I have got the following code:
F (S core ps) = FAll core [] ps
where
FAll core acc ((name, (pc : pcs)) : ps)
= case F' (pc : pcs) (readC pc core) core of
Nothing ->
if (length pcs) /= 0 then FAll core ((name, pcs) : acc) ps
else FAll core acc ps
Just (core', [pc']) -> let
pc'' = pc' `mod` coresize
pcs' = pcs ++ [pc'']
in FAll core' ((name, pcs') : acc) ps
stepAll core acc [] = S core (reverse acc)
It compiles fine but when I run the program it gives the following error:
Melon.hs:(172,10)-(182,74): Non-exhaustive patterns in case
where the number indicating the rows are the ones from the "= case F' (pc : pcs) (readC pc core) core of" to the "in FAll core' ((name, pcs') : acc) ps"
I think the problem is in exhausting the pattern for (pc : pcs) but I just cannot understand how I can solve it.
Any help would be appreciated.
The code has been updated with this one:
I wrote the following:
Just (core', (pc' : pcs')) -> let
pc'' = pc' `mod` coresize
pcs' = pcs' ++ [pc'']
in stepAll core' ((name, pcs') : acc) ps
Just (core', []) -> stepAll core acc ps
but the program just falls into an infinite loop :S