i'm trying to parse an input in haskell so that i can transform it to a custom type.
The input consists of a name variable, followed by a list of values and their abbreviations like this
colour:red=r,blue=b,green=g
I defined my type as Var = (string,[value])
I'm fairly new to haskell so my first instinct was to (mistakenly) try and pattern match like this
parseVar :: String -> Var
parseVar (y:':':v) = (y, parseValueList v)
the problem is i cant do that because y
has to be a string. My question is: is there a way to pattern match with an indefinite length string as long as i know the separator symbol? (in this case ':'
)
I know this could be done in a different way but i just want to know if that is a tool i can use