Getting <<loop>> Exception in Haskell Depending on Pattern Arrangement -
someone can please explain why getting loop in code?
module main import data.list.split import data.maybe import text.read main :: io () main = print (snd (toinmetdate "01/02/2012")) type p = (bool, a) readp :: (read a) => string -> p readp text | isjust value = (true, fromjust value) | isnothing value = (false, read "0") value = readmaybe text data inmetdate = inmetdate {dia :: p int, mes :: p int, ano :: p integer} deriving (show, read) toinmetdate :: string -> p inmetdate toinmetdate x = if length l == 3 (true, inmetdate (readp ds) (readp ms) (readp as)) else (false, inmetdate (false, 0) (false, 0) (false, 0)) (l,ds:ms:as:_) = (spliton "/" x, l ++ replicate 20 "null")
i state that, when make:
(l,ds:ms:as:_) = (spliton "/" x, l ++ replicate 20 "null")
equal to:
(ds:ms:as:_) = l ++ replicate 20 "null" l = spliton "/" x
the code work perfectly.
in original, value of l
depends on tuple recursively defined in terms of l
. in change, l
depends solely on value of spliton "/" x
.
Comments
Post a Comment