On 2008-01-04 0:23, Bulat Ziganshin wrote:
Hello C.M.Brown,

Thursday, January 3, 2008, 10:46:54 PM, you wrote:

i don't use
type signatures at all - this creates some problems when i wrote large
portion of code and try to make it compile, but nothing more

I believe type signatures are the very essence of Haskell documentation!
I'd much rather see a program with type signatures for functions and
little (or no) comments over programs with no type signatures and
ambigious comments (if any comments at all!).

Type signatures really does make dealing with someone elses code that
much easier.

well, i don't worry about types of things with which i work. i know
that it is a file, for example. its actual type depends on the
information i need inside this function. it may start as FileInfo type,
then after refactoring it will become CompressedFile or
(fileInfo,FileSize) type. while it's great to know types of every
variable to better understand how program works, adding type
signatures means more work when writing program and when changing it.
i want to express only data processing algorithm leaving all the
details to compiler. for me, ghc just "reads thoughts"

types and type signatures was required in classic languages to fight
with errors. but in haskell omitting type signatures doesn't make
program less reliable, so i don't need to write this extra code in
addition to the essential - algorithm itself. for the same reason, i
like pointless notation


You are wrong. Without type signatures some type errors will not be
caught by the compiler, resulting in erroneous program behaviour.
An example:

makeURI file index = "http://192.168.0.1/somescript.php?file="; ++
   urlEncode file ++ "&index=" ++ show index

the intended signature for the above function is:
String -> Int -> String, but suppose I've used it that way:
makeURI "somefile.txt" "1"
this is a type error, String was used where Int was expected,
but the program compiles just fine. So now the string:
http://192.168.0.1/somescript.php?file=somefile.txt&index="1";
will be sent to the server which is of course wrong because
http://192.168.0.1/somescript.php?file=somefile.txt&index=1
is expected.

Without type declarations You are not using the full power
of static type checking.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to