
If it's a practical question, rather than a theoretical one, I use
this: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts...
On Mon, Jun 20, 2016 at 8:03 AM, Tom Ellis
Is it compatible with the semantics of Haskell to have a function
sourceLocation :: IO String
which when run returns the source file location at which it is used? For example, suppose Main.hs is
module Main where
main = do putStrLn =<< sourceLocation putStrLn "Hello" putStrLn =<< sourceLocation
It would print the following when run
Main.hs:4 Hello Main.hs:6
and
module Main where
main = do let s = sourceLocation putStrLn =<< s putStrLn "Hello" putStrLn =<< s
It would print the following when run
Main.hs:4 Hello Main.hs:4
If this is not compatible with the semantics of Haskell, why not? I agree that the two programs must have the same denotation, but is there anything that requires them to have the same output when run?
Tom
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.