[Nix-dev] haskell ide
Mathijs Kwik
mathijs at bluescreen303.nl
Mon May 12 23:02:19 CEST 2014
> On 05/11/2014 09:50 AM, Roelof Wobben wrote:
>>
>> but can someone explain to me what holes and missing cases are.
>
Sorry, I missed this part of your question somehow.
While I agree with Vladimir that there's already an immense lot to
learn with just the basic haskell2010 stuff/concepts, these 2 features
_are_ useful while learning. And the reason I mentioned these, is
because they _are_ tightly bound to advanced editor support. Something
which at the moment only emacs and vim provide.
Both have to do with getting "stuck" in a place in your code, where
you would like a hint and ask the compiler "what do you expect me to
type here?".
In the case of holes (a ghc 7.8 extension) you can place an underscore
somewhere in your code, and ghc will treat it like "undefined", but
provide good information of what type is needed in that "hole" and
what the other variables in scope are. This is very very helpful if
you are nested below top-level (where clause for example) and really
teaches you to think about types and just filling the details. See
http://www.haskell.org/haskellwiki/GHC/TypedHoles for more info.
Missing cases have been available for a long time as well (as
compilation warnings) to warn you about cases you forgot to specify.
data TrafficLight = Red | Orange | Green
handleLight :: TrafficLight -> IO ()
handleLight Red = stopTheCar
handleLight Green = hitTheGas
In this case, it's clear that this function forgot to specify what to
do on orange. Of course examples can get far more difficult when
fancier types are involved, or when combinations were tried (Orange |
mySpeed > 30) but not all of them.
Both these things are of course available as console output on
compilations so you _can_ use them next to whichever editor you use.
But of course if your editor integrates deeply with this machinery
(like a REPL/editor conversation), this means you can have your editor
fill in the missing cases, or create new cases by just expanding over
a variable name via a keystroke or mouse menu.
Once again, you can absolutely do without these features. But if you
are going to learn a new editor/ide anyway, I would stick to the 2
giants instead of to some glorified notepad with a few fancy buttons
which only highlights some keywords, without understanding language
structure itself :)
More information about the nix-dev
mailing list