Le 12/07/2018 à 15:01, Brett Gilio reacts :

Alexey, could you expand on what you mean in your first point? I am quite intrigued. I do not use Haskell often, but that could be something of interest to me in-and-out of Haskell.

Brett Gilio

Alexey Raga wrote:
...major reasons

1. The ability to define the specification (types) and then "just" follow them in implementation. Sometimes even without having a clear understanding of the things I was using, I felt (and still feel) guided towards the right solution.
I am not Alexey Raga, who precises:
when I wrote a signature for my function, the compiler will make its best to help me implement it. It will yell at me, it will not let me use things that I am not supposed to use (according to constraints), etc.
===
... but I think that there is more to tell, since in *all languages* the compiler makes its best to profit from typing in order to optimize the implementation...
With polymorphic typing and automatic type inference, the compiler can do a little more, it seems that people forgot already the "toy" (not so...) of Lennart Augustsson, named Djinn, which takes a type and proposes an object of this type, using the intuitionistic logic theorem prover (the current Djinn library dates back to 2014, but Lennart manufactured  it already in 2006, or before,  if I am not mistaken. He quotes Roy Dyckhoff, and Don Stewart). Here is a test:

Djinn> f ? (a,b) -> (b,a)   -- my input
f :: (a, b) -> (b, a)
f (a, b) = (b, a)

Doaitse Swierstra comments:
swap (a, b) = (b, a)

Once you ask for the type you get (a, b) -> (b, a), hence the type completely specifies what swap computes, and the function is even more general than the version of the type above.
I don't see that last point... Anyway, the typing power of Haskell should be known.
Thx.

Jerzy Karczmarczuk


 

 


Garanti sans virus. www.avast.com