logoalt Hacker News

itishappy11/08/20242 repliesview on HN

    {-# LANGUAGE OverloadedStrings #-}

    import Prelude hiding (putStrLn)
    import Data.Text (Text, replace)
    import Data.Text.IO (putStrLn)

    transform :: Text -> Text
    transform = replace "k" "sk" . replace "ke" "-ki" 

    main :: IO ()
    main = putStrLn $ transform "Haskell"

Replies

sshine11/11/2024

Since the original sed command took "Haskell" as standard input, why not:

  {-# LANGUAGE OverloadedStrings #-}

  import qualified Data.Text as T
  import qualified Data.Text.IO as T

  main :: IO ()
  main = T.interact (T.replace "k" "sk" . T.replace "ke" "-ki")
show 1 reply
fuzztester11/10/2024

Looks good to me, even as a Haskell ignoramus. I had tried it long back, but found it tough at the time.

What is the reason for hiding the putStrLn of Prelude and importing that of Data.Text.IO?

show 1 reply