etFileName :: LazymailCurses FilePath
getFileName = do
  st <- get
  let cs = composeState st
  case bodyFileName cs of
    Just fp -> return fp
    Nothing -> do
      fp <- liftIO $ newFilename
      let cs = (composeState st) { bodyFileName = Just fp }
      put $ st { composeState = cs }
      return fp

  where
    newFilename = do
      tmp <- getTemporaryDirectory
      num <- getRandomNumber
      return $ (tmp </>) $ ("lazymail-" ++ ) $ show num

getFileName :: LazymailCurses FilePath
getFileName = do
  st <- get
  let cs = composeState st
  case bodyFileName cs of
    Just fp -> return fp
    Nothing -> do
      fp <- liftIO $ newFilename
      let cs = (composeState st) { bodyFileName = Just fp }
      put $ st { composeState = cs }
      return fp

  where
    newFilename = do
      tmp <- getTemporaryDirectory
      num <- getRandomNumber
      return $ (tmp </>) $ ("lazymail-" ++ ) $ show num
getFileName = do
  st <- get
  let cs = composeState st
  case bodyFileName cs of
    Just fp -> return fp
    Nothing -> do
      fp <- liftIO $ newFilename
      let cs = (composeState st) { bodyFileName = Just fp }
      put $ st { composeState = cs }
      return fp

  where
    newFilename = do
      tmp <- getTemporaryDirectory
      num <- getRandomNumber
      return $ (tmp </>) $ ("lazymail-" ++ ) $ show num