samedi 22 mars 2014

How To Use Triangle Operators In Pattern Matching Function


Vote count:

0




I'm trying to use Sequences to improve performance. When defining the function below I tried to use the "triangle" operators in pattern patching context.



import qualified Data.Sequence as S

cleanField :: S.Seq Char -> S.Seq Char
cleanField ((S.<|) ' ' xs) = cleanField xs
cleanField ((S.|>) xs ' ') = cleanField xs
cleanField xs = xs


GHC 7.4.1 says: seq.hs:4:13: Parse error in pattern: (S.<|)


Can I not use the triangle operators (<|,|>)in pattern matching?


If so, why can I use the cons (:) operator in pattern matching and not the triangle operators?



asked 4 mins ago

awashburn

1,564





Aucun commentaire:

Enregistrer un commentaire