6 Oct 22:28
Re: I want my free (and good looking) parser!
From: Slavomir Kaslev <slavomir.kaslev <at> gmail.com>
Subject: Re: I want my free (and good looking) parser!
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-10-06 20:28:46 GMT
Subject: Re: I want my free (and good looking) parser!
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-10-06 20:28:46 GMT
On Mon, Oct 6, 2008 at 9:36 PM, Christian Maeder <Christian.Maeder <at> dfki.de> wrote: > import Text.ParserCombinators.Parsec > > freeParser :: (Enum a, Bounded a, Show a) => Parser a > freeParser = choice $ map (\ a -> try $ do > string $ show a > notFollowedBy (alphaNum <|> char '_') > return a) [minBound .. maxBound] > This is exactly what I needed. Though I still don't quite understand why this works and mine doesn't. > I see not need for extensions. (And I don't like > Text.ParserCombinators.Parsec.Token) > > Where did you get enumAll from? > Mine definition of enumAll was equivаlent to [minBound .. maxBound]: enumAll :: (Bounded a, Enum a) => [a] еnumAll = enumFromTo minBound maxBound > The type of the Parser must be deducible from the context (or given by a > type annotation). > > Cheers C. > > Slavomir Kaslev wrote:(Continue reading)
RSS Feed