[Haskell-cafe] request for code review

Scott Turner p.turner at computer.org
Sun Mar 5 18:01:46 EST 2006


On 2006 March 05 Sunday 05:43, Shannon -jj Behrens wrote:
> classifyString s        = Token (whichType s) s
>   where whichType "volatile" = Qualifier
>         whichType "void"     = Type
>         whichType "char"     = Type
>         whichType "signed"   = Type
>         whichType "unsigned" = Type
>         whichType "short"    = Type
>         whichType "int"      = Type
>         whichType "long"     = Type
>         whichType "float"    = Type
>         whichType "double"   = Type
>         whichType "struct"   = Type
>         whichType "union"    = Type
>         whichType "enum"     = Type
>         whichType _          = Identifier

whichType doesn't need to be a function.

classifyString s        = Token whichType s
  where whichType = case s of
	    "volatile" -> Qualifier
	    "void"     -> Type
	    "char"     -> Type
	    "signed"   -> Type
	    "unsigned" -> Type
	    "short"    -> Type
	    "int"      -> Type
	    "long"     -> Type
	    "float"    -> Type
	    "double"   -> Type
	    "struct"   -> Type
	    "union"    -> Type
	    "enum"     -> Type
	    _          -> Identifier


More information about the Haskell-Cafe mailing list