[Haskell-beginners] why is something different within a function when it comes out?

prad prad at towardsfreedom.com
Wed Jul 14 01:33:10 EDT 2010


i have this:


main = do
    
    c <- readFile "test.txt"
    let tleP = "<title>\n(.*)\n</title>"
    let tle = c=~tleP::[[String]]
    putStrLn $ tle!!0!!1

    let g = xtract tleP c
    putStrLn $ show g 


xtract p c = do
    let r = c=~p::[[String]]
    return r!!0!!0!!1

for the first putStrLn i get:
League of Humane Voters Home Page

for the second i get 
"League of Humane Voters Home Page"
but only after i have done r !!0 !!0 !!1

whereas i only needed tle !!0 !!1

it seems to me that both tle and r serve the same purpose though they
come out as different types r being a string and tle being i don't know
what because i get a "Not in scope: 'tle'

so even though both r and tle are set as [[String]], they don't seem to
be the same creature.

-- 
In friendship,
prad

                                      ... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's


More information about the Beginners mailing list