Skip to content

Instantly share code, notes, and snippets.

@mkscrg
Created June 12, 2013 06:48
Show Gist options
  • Save mkscrg/5763306 to your computer and use it in GitHub Desktop.
Save mkscrg/5763306 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Data.Char
import Data.Attoparsec.Text
import Data.Text (Text)
main :: IO ()
main = getArgs >>= print . parseOnly identifier . read . head
identifier :: Parser Text
identifier = "$" .*> (withBraces <|> withoutBraces)
where
withBraces = "{" .*> takeWhile1 (/= '}') <*. "}"
withoutBraces = takeWhile1 isAlphaNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment