Someone can please explain why I am getting a loop in this code?
module Main where
import Data.List.Split
import Data.Maybe
import Text.Read
main :: IO ()
main = print (snd (toInmetDate "01/02/2012"))
type P a = (Bool, a)
readP :: (Read a) => String -> P a
readP text
  | isJust value    = (True, fromJust value)
  | isNothing value = (False, read "0")
  where 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
  then  (True, InmetDate (readP ds) (readP ms) (readP as))
  else  (False, InmetDate (False, 0) (False, 0) (False, 0))
  where (l,ds:ms:as:_) = (splitOn "/" x, l ++ replicate 20 "NULL")
I would state that, when I make:
  where (l,ds:ms:as:_) = (splitOn "/" x, l ++ replicate 20 "NULL")
equal to:
  where (ds:ms:as:_) = l ++ replicate 20 "NULL"
        l = splitOn "/" x
the code work perfectly.
 
    