[Haskell-cafe] ByteString in patterns
Don Stewart
dons at galois.com
Tue Mar 10 18:42:59 EDT 2009
manlio_perillo:
> Hi.
>
> Using normal String type I can define a pattern like:
>
> > let foo "baz" = 777
> > foo "baz"
> 777
>
>
> But if I want to use ByteString, what should I do?
> This seems impossible, since ByteString data constructor is not available.
-XOverloadedStrings
e.g.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as C
isMatch :: C.ByteString -> Bool
isMatch "match" = True
isMatch _ = False
main = print . map isMatch . C.lines =<< C.getContents
More information about the Haskell-Cafe
mailing list