haskell-problem: io string -> [int] -


hello great programmers out there,

i'm doing first steps in haskell , have function confuses me:

import data.list.split getncheck_guesslist =     line <- getline     let tmp = splitoneof ",;" line     map read tmp::[int] 

splitoneof in data.list.split (i installed cabal install split) splitoneof :: (eq a)=> [a]->[a]->[[a]]

from error there type incorrectness - don't know how solve conflicts io still mystery me

i want read input of integers separated commas or semicolons , list of integers so:

  • how can check if user input of type int
  • how can "translate" input of type "io string" [int]

thank in advance thoughts , hints - yours ε/2

when you're writing function uses io monad, value want return function must in io monad.

this means that, instead of returning value type [int], have return type io [int]. this, use return function, "wraps up" value io (it works any monad).

just change last line wrap value return, this:

getncheck_guesslist =     line <- getline     let tmp = splitoneof ",;" line     return (map read tmp :: [int]) 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -