I have defined a type as:
type Register = Int
I’m also able to read in a list of numbers from a list of Strings using a function like:
readInt :: String -> Int
readInt s = read s :: Int
now, using readInt on a list like readInt "12 32 11" gives me [12, 32, 11] which is of type [Int].
My question is: instead of [Int], how can I get [Register].
I tried:
readRegister :: String -> Register
readRegister s = read s :: Register
but as I guessed, it doesn’t seem to be valid syntax.
Your definition of
Registeris a type alias, i.e. it is interchangeable with its right hand side, i.e. here withInt.But you state that
readInt "12 32 11"would yield[12,32,11] :: [Int]. This is impossible given your type signature ofreadInt :: String -> Int. Perhaps you could show us a bit more of your code.