ZVON > References > Haskell reference
| Indexes | Syntax | >> Prelude << | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Prelude
Function: read
Type: Read a => String -> a
Description: casts strings to another type
Related: lex, reads, show, shows
Bibliography: The Read and Show Classes [ A Gentle Introduction to Haskell ]

Example 1

Input: read "12"::Int

Output: 12

Example 2

Input: read "12"::Double

Output: 12.0

Example 3

Input: read "1.22"::Double

Output: 1.22

Example 4
Program source: 

main = print (rInt "12",rBool "True")

rInt :: String -> Int
rInt = read

rBool :: String -> Bool
rBool = read

Output: (12,True)