[clean-list] Does (<!?>) mean the element is optional?

metaperl metaperl at gmail.com
Thu Aug 28 19:26:42 MEST 2008




metaperl wrote:
> 
> The docs for (<!?>) say:
> // takes an element if it is there
> <!?>		:: (Parser s r t) (r -> u) u -> Parser s u t
> 
> 
> So I'm wondering if that means this parse always succeeds even if what it
> is looking for is not there. Concretely, in the case below it would mean:
> "The Date and Time Prefix is entirely optional and the parse continues
> without error, even if it is not found"
> 
> // metar prefix
> 
> metarPrefix :: Parser [Char] Char t
> metarPrefix = "Date and Time Prefix (four or six digits followed by Z)" :>
> (word p)
> where	p =  twoDigits &> twoDigits &> (<!?> twoDigits undef undef) &>
> (symbol 'Z')
> 
> // metar
> 
> metar :: Parser [Char] MetarData t
> metar = (<!?> metarPrefix undef undef) &> metarData
> 

No Terrence, it is a monadic style combinator:

// monadic sequential-combinator
(<&>)	infixr 6 :: (Parser s u t) (u -> Parser s v t)	-> Parser s v t



-- 
View this message in context: http://www.nabble.com/Does-%28%3C%21-%3E%29-mean-the-element-is-optional--tp19167295p19205280.html
Sent from the Clean mailing list archive at Nabble.com.



More information about the clean-list mailing list