readSquareTransition :: String -> Maybe [SquareTurn]
readSquareTransition [] = Just []
readSquareTransition (x:xs) = case x of
'L' -> Just (L : readSquareTransition xs)
'R' -> Just (R : readSquareTransition xs)
_ -> Nothing
私はちょうど[L、L、R、R]になりたいです。私は失敗したように:(ここでエラーメッセージがあるけどね!このハスケルの文字列リストへ
'L' -> fmap (L :) $ readSquareTransition xs
'R' -> fmap (R :) $ readSquareTransition xs
へ
src/StudentSources/LangtonsAnt.hs:231:24:
Couldn't match expected type ‘[SquareTurn]’
with actual type ‘Maybe [SquareTurn]’
In the second argument of ‘(:)’, namely ‘readSquareTransition xs’
In the first argument of ‘Just’, namely
‘(L : readSquareTransition xs)’
src/StudentSources/LangtonsAnt.hs:232:24:
Couldn't match expected type ‘[SquareTurn]’
with actual type ‘Maybe [SquareTurn]’
In the second argument of ‘(:)’, namely ‘readSquareTransition xs’
In the first argument of ‘Just’, namely
‘(R : readSquareTransition xs)’
あなたは 'Just'を削除する必要があります:' readSquareTransition'は既に何かを返します。 – gallais
おっと、私は不注意でした、あなたは正しいです、私はこれを変更します.... – jamshidh
'readSquareTransition xs'や' $ 'の前にカッコを付けたり、'(<$>) 'の代わりに'fmap'。 – gallais