- | Function in charge of showing the application of the type constructor "ghc-prim:GHC.Types.:"
showList :: Ty -> [Pointer] -> IM String
showList ty ptrs = do
  io $ putStrLn " LIST"
  elem_strs <- mapM (showPtr ?? showValue) ptrs
  case ty of
    Tvar("ghc-prim:GHC.Types.Char") -> return $ "\"" ++ map (!! 1) elem_strs ++ "\""
    _ -> return $ "[" ++ separateWithCommas elem_strs ++ "]"
      
    -- If we find an empty list, we ought not show it as [] but rather as the empty string
  where
    -- If we find another list, don't show the []
    showValue' :: Value -> IM String
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) []) = return ""
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) [ptr]) = (showPtr ?? showValue') ptr       
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.:" _ _) ptrs) = mapM (showPtr ?? showValue') ptrs >>= return . separateWithSpaces
    showValue' t@(TyCon (MkDataCon "ghc-prim:GHC.Types.[]" [] _) "ghc-prim:GHC.Types.[]")= return ""
    showValue' v = showValue v
  
-- from the operators of the package `lens`

showList :: Ty -> [Pointer] -> IM String
showList ty ptrs = do
  io $ putStrLn " LIST"
  elem_strs <- mapM (showPtr ?? showValue) ptrs
  case ty of
    Tvar("ghc-prim:GHC.Types.Char") -> return $ "\"" ++ map (!! 1) elem_strs ++ "\""
    _ -> return $ "[" ++ separateWithCommas elem_strs ++ "]"
      
    -- If we find an empty list, we ought not show it as [] but rather as the empty string
  where
    -- If we find another list, don't show the []
    showValue' :: Value -> IM String
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) []) = return ""
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) [ptr]) = (showPtr ?? showValue') ptr       
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.:" _ _) ptrs) = mapM (showPtr ?? showValue') ptrs >>= return . separateWithSpaces
    showValue' t@(TyCon (MkDataCon "ghc-prim:GHC.Types.[]" [] _) "ghc-prim:GHC.Types.[]")= return ""
    showValue' v = showValue v
  
-- from the operators of the package `lens`
showList ty ptrs = do
  io $ putStrLn " LIST"
  elem_strs <- mapM (showPtr ?? showValue) ptrs
  case ty of
    Tvar("ghc-prim:GHC.Types.Char") -> return $ "\"" ++ map (!! 1) elem_strs ++ "\""
    _ -> return $ "[" ++ separateWithCommas elem_strs ++ "]"
      
    -- If we find an empty list, we ought not show it as [] but rather as the empty string
  where
    -- If we find another list, don't show the []
    showValue' :: Value -> IM String
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) []) = return ""
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.[]" _ _) [ptr]) = (showPtr ?? showValue') ptr       
    showValue' t@(TyConApp (MkDataCon "ghc-prim:GHC.Types.:" _ _) ptrs) = mapM (showPtr ?? showValue') ptrs >>= return . separateWithSpaces
    showValue' t@(TyCon (MkDataCon "ghc-prim:GHC.Types.[]" [] _) "ghc-prim:GHC.Types.[]")= return ""
    showValue' v = showValue v
  
-- from the operators of the package `lens`