You can add an arbitrary warnings to functions by adding a documentation comment starting with warning:. However, if such comments are added to members of data or class and they are called by "method-style" (what is the correct term for this?), the compiler doesn't warn about them.
Example:
module Main where
data Foo = Foo Int
where
--- warning: don't use this!
get :: Foo -> Int
get (Foo x) = x
class Hello a where
--- warning: don't use this either!
hello :: a -> String
instance Hello Foo where
hello (Foo x) = show x
main :: IO ()
main = do
let foo = Foo 1
-- these get warnings
println (Foo.get foo)
println (hello foo)
-- but these don't
println foo.get
println foo.hello
The output of the compiler:
$ java -jar fregec.jar -ascii Main.fr
W Main.fr:20: Foo.get: don't use this!
W Main.fr:21: Hello.hello: don't use this either!
calling: javac -cp fregec.jar:. -d . -sourcepath . -encoding UTF-8 ./Main.java
You can add an arbitrary warnings to functions by adding a documentation comment starting with
warning:. However, if such comments are added to members ofdataorclassand they are called by "method-style" (what is the correct term for this?), the compiler doesn't warn about them.Example:
The output of the compiler: