For this you probably want to use a lambda:
takeTill (\x -> x == '\t' || x == '\n')
A lambda function is an anonymous, one-use, inline function. You can use them just like normal functions, except they aren't bound to a name.
You could also define a function
tabOrNL :: Char -> Bool
tabOrNL '\t' = True
tabOrNL '\n' = True
tabOrNL _ = False
-- Or equivalently
tabOrNL :: Char -> Bool
tabOrNL x = x == '\t' || x == '\n'
Then you could just do
takeTill tabOrNL
If you wanted to get really fancy, the Applicative
instance for functions can come in handy here:
(<||>) :: Applicative f => f Bool -> f Bool -> f Bool
(<||>) = liftA2 (||)
infixr 2 <||>
Then you can just do
takeTill ((== '\t') <||> (== '\n'))
Or even
takeTill ((== '\t') <||> (== '\n') <||> (== ','))
That way you avoid the lambda or helper function entirely, the <||>
lets you just "or together" several predicates as if they were values. You can do similarly with (<&&>) = liftA2 (&&)
, but it's probably not as useful for you here.