Reputation: 231
I have the following string [1..5]
and I want to convert it to the Integer list [1,2,3,4,5]. I tried doing this using read but that does not work. Is there any simple trick to convert such a list to an Integer list or will it require a parser?
Upvotes: 4
Views: 320
Reputation: 3749
I guess you will need an interpreter to do so. You might want to do something along the line of:
$ cabal install hint
...
$ ghci
> import Language.Haskell.Interpreter
> runInterpreter $ setImports ["Prelude"] >> eval "[1..5]"
Also see this answer: https://stackoverflow.com/a/5584638/55070
Upvotes: 4