Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - import Text.Printf
- myPutStrLn = putStrLn . (++) "log: "
- -- GHC infers `myPrintf :: String -> IO ()' which is not what I want.
- myPrintf = logger . printf
- where
- -- note, this is just an example. should be replaceable with any function
- -- with this typesignature
- logger :: String -> IO ()
- logger = putStrLn . (++) "log: "
- main = do
- -- Instead, I would like to write
- myPrintf "test %d" (23 :: Int)
- -- but it fails with
- {-hprintf.hs:26:3:
- The function `myPrintf' is applied to two arguments,
- but its type `String -> IO ()' has only one
- In a stmt of a 'do' block: myPrintf "test %d" 23
- In the expression:
- do { myPutStrLn "hello";
- myPutStrLn $ printf "test %d" (23 :: Int);
- myPrintf "test %d" 23 }
- In an equation for `main':
- main
- = do { myPutStrLn "hello";
- myPutStrLn $ printf "test %d" (23 :: Int);
- myPrintf "test %d" 23 }
- -}
                    Add Comment                
                
                        Please, Sign In to add comment                    
                 
                    