We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

A quick overview of the Haskell tooling

00:00

Formal Metadata

Title
A quick overview of the Haskell tooling
Title of Series
Number of Parts
542
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Since the beginning of the language, many interesting tools were implemented for developing in Haskell (REPL, central package archive, property-based testing...). Today, the Haskell tooling provides several powerful and intuitive setups. This talk will present some useful features provided in a classic modern setup (cabal + HLS + vscode). Some of these features are also widespread in other programming languages, some are more specific to the Haskell world.
ComputerPersonal digital assistantCodeCompilerImplementationInstallation artSource codeComputer programView (database)Repository (publishing)Array data structureVector spaceSubject indexingMathematical optimizationLoop (music)Software frameworkType theoryVector graphicsAdaptive behaviorFamilyRepresentation (politics)Primitive (album)Instance (computer science)AirfoilHookingGoogolQuery languageNormed vector spaceFunction (mathematics)Electronic signatureApproximationEmailRevision controlMusical ensembleWeb pageRestgliedArrow of timeCommutative propertyDistribution (mathematics)Physical systemBuildingLibrary (computing)Default (computer science)Formal languageGastropod shellUser profileRepetitionBendingNetwork topologyElectronic mailing listLetterpress printingVisual systemModule (mathematics)Asynchronous Transfer ModeContent (media)Integrated development environmentParameter (computer programming)Keyboard shortcutString (computer science)Computer configurationConfiguration spacePrice indexSoftware testingExecution unitLink (knot theory)Type theoryExpressionComputer fileCodeConfiguration spacePower (physics)Projective planeoutputFunctional (mathematics)CompilerGraph coloringLibrary (computing)WebsiteOperator (mathematics)Message passingSoftware testingSemiconductor memoryResultantUnit testingNeuroinformatikLoop (music)Personal digital assistantInformationFunctional programmingBuildingSource codeInterpreter (computing)Computer programmingVisualization (computer graphics)Plug-in (computing)Error messageINTEGRALStack (abstract data type)Complete metric spaceSoftware developerPointer (computer programming)Open setString (computer science)File archiverText editorComputer animationLecture/Conference
Gastropod shellSuite (music)Software testingNetwork topologyMountain passCodeUser profileBuildingPersonal digital assistantElectronic mailing listCategory of beingPraxisbudget Quick CheckSlide ruleState of matterArchaeological field surveyVariety (linguistics)Taylor seriesBlogModule (mathematics)Discrete element methodLibrary (computing)Revision controlBendingInstance (computer science)Loop (music)Integrated development environmentPhysical systemContent (media)String (computer science)Keyboard shortcutParameter (computer programming)HypothesisoutputBoolean algebraExpressionProjective planeVisualization (computer graphics)Computer programmingFreezingSimilarity (geometry)Integrated development environmentDifferent (Kate Ryan album)Software testingCodeMultiplication signText editorINTEGRALStack (abstract data type)Computer fileInstallation artSlide ruleCategory of beingPower (physics)CompilerRun-time systemRevision controlExtension (kinesiology)PlanningDebuggerFormal languageFunctional (mathematics)Semiconductor memoryComputer animationLecture/Conference
CodeKeyboard shortcutNetwork topologyContent (media)Parameter (computer programming)String (computer science)Electronic mailing listPrisoner's dilemmaComputer animationProgram flowchart
Transcript: English(auto-generated)
OK, so here is a quick overview of the Haskell tooling. I am Julien De Rosse. I am an assistant professor in computer science, and I use Haskell since 2015, initially for teaching functional programming. So since the beginning of the language,
Haskell has many tools that have been created for developing in Haskell. And today, most of the Haskell developers use a GHC compiler. For building Haskell projects, we have a nice tool, such as Kerbal or Stack. Haskell is now quite well-integrated in editors, such as Visual Studio Code, VM, or Emacs,
thanks to LSP implementations, such as HLS. And all these tools can be installed using some tools, like GHC-UP or Nix. In this talk, I will focus on Kerbal with VSCode and the Haskell. Haskell plugin.
First, we have some online tools, such as Package, which is a package archive. So you can go to the website and search for packages. There is, for example, some libraries for doing whatever you want. These libraries, you can access their documentation
so you can see what to do with this library and how to use it. And you also have access to their source code with nice colors and code navigation, which is quite useful. We also have Hooger, which is Haskell Google. So it's a search engine.
And you can type the memory function, and Hooger will give you a link to the documentation of the function in the package. If you don't know the name of the function, you can also write the type of the function, and Hooger will try to find functions that match that type. So you can see its documentation on the package
and see if it's the function you are looking for. Okay, to work on the Haskell project, you can use Cabal, which is a tool for building and packaging projects. To use Cabal, we have to write a Cabal file, which is a configuration file
where you can specify some information about your project and also define the target you want to build in your project. So for example, if you have a library or executables, you can write them here. Or you can also add some dependencies, for example, libraries available on Acage.
Then you can use the Cabal tool once we have this file. So we can run Cabal build to build our targets. When we do that, Cabal will get the dependencies from Acage and run the compiler to build all your files. We also have the Cabal run command to run specific targets
and can also give command line arguments if your program requires that. We have a repo, which is a read-eval-print loop. So this runs the compiler in an interpreter mode, so we can write some Haskell expressions and the compiler will evaluate these expressions
and print the result. So it's very interesting for testing some code. And you have also more specific commands. For example, here you can ask some information about the type of function or anything. Okay, so to work on a Haskell project, we can use editors like Visual Studio Code
with HLS and the Haskell.hascal plugin. It's a very tasty tool. So you have the file of your project. You can open them, edit them. You also have code navigation and documentation. So if I put the mouse pointer over a function,
VS Code will show me the documentation of that function. And if I control click on the function, VS Code goes to the definition of the function. We also have code completion. So VS Code tries to complete the code you are typing. We have an integration of the compiler.
So if there is an error in your code, VS Code will show you where is this error and it can give you the message from the compiler. Even if your code is correct, VS Code can help you improve your code. It can give some hints to refactor it. So for example here, it says that my code is correct,
but it would be better if I use the FMAP operator instead of the FMAP function. We also have holes, which is, let's say you are writing some code and you don't know what to write at a specific place, you can put this underscore character
and the compiler will tell you what you'd expect at this place. For example, here it says that it waits for a function that takes a string and returns an int. We have an inline ripple. So you can type some Haskell expressions as commands in your code with a specific prefix.
And when we do that, VS Code will print a button, will show a button, and if you click on this button, it will evaluate your expressions and add the result of these expressions in the comments below. So it can be very useful for adding some examples as commands in your code for documenting the code.
Speaking of documentation, we have Hadoop, which is a classic tool where we write documentation of our project as command inside the code. And then we can run cable-hadoop and this generates documentation as HTML file,
which look like this. As you can see, it's a tool that is used for generating the documentation on HAKH. And finally, we have some tools for testing our project. First of all, Haskell has a quite powerful type system, so it already prevent us from writing many errors, but we still need to test our code.
We can do that with a very classic unit test. So for example here, we just write a Haskell expression with a specific input and call a function on that input, and we can write the value that we expect for this input. So we can write many inputs to test
and test many functions, and when we run cable test, this will compile our testing program and run it, and it checks that every expression is evaluated and returns the expected value. If there is a problem in one of the tests, cable test will tell us which function fails.
We have more than that. We can use property-based testing instead of giving a specific input, we can write a property, which is a function that takes an argument and return a Boolean, and this Boolean says if the property is satisfied or not.
And when we do that, QuickCheck will generate random inputs. Here it says that it has generated 100 inputs, and it tests the properties on each input. If one input makes a test fail, QuickCheck will try to shrink the input to the smallest value,
such that it's simpler for us to debug our program. Okay, to conclude, Haskell has done nice tools for many years. All these tools, cable, QuickCheck, are quite old, and now they will mature. And since more recently, we have very nice integrations in editors
like VS Code or other editors. This is quite easy to install, at least on Linux. You just have to install ghcup, VS Code, and the Haskell. Haskell plugin, and that's it. You have a nice Haskell environment for developing your project. This slide and the code shown here
are available at this link. You can also see the tooling below, which presents other alternatives. So if you prefer to use VM or Emacs, there is a tool you can use to do that. And that's all from me. Thank you for your attention.
Thank you very much, Julia. There is time for questions. Five minutes. Just shout it out, and we can repeat the question. What is the difference, you showed us the cable that you prefer to,
what is the difference between the cable REPL and just using JHCI? Can you please repeat the question? So what is the difference between the cable REPL and the JHCI, which is a REPL from the compiler? In fact, I think it's quite the same tool. Cable will call the JHCI,
so the REPL from the compiler. But if your project has some specific dependencies or some modules, the cable REPL will take all of that into account so you can inspect that code and quite more powerful. But it's the same tool at the end.
Which tools do you recommend for debugging Haskell? I don't use very much the Haskell debugger. There is a debugger. Debugging in Haskell is quite different from other languages, I think. So there is a debugger where you can inspect memory
or the runtime system using the JHC compiler. But it's not something that I can do very well. So I won't recommend anything.
There's, in your examples, you showed that you can have comments evaluated as a REPL. Is that a VS Code extension-specific thing? Because I know Rust has something quite similar and it makes sure that examples in your documentation compile and pass tests.
Can you do similar sorts of things? So we just, can I, what can I? You had an example of a REPL evaluated in comments in your code. Ah, okay. This one. Yeah, is that specific to the VS Code extension?
I think so. It's provided by Visual Studio Code with the SQL extension and it's automatic, I think. Yeah, Rust has this feature. Yeah, okay. The evaluators, you're doing your tests for your notes. Yeah, it's. It'd be nice to pass it with that. Does that work? It does.
Yeah, so what is very confusing for beginners sometimes if you come from another language like Rust or so, then it's one way to build a project and in Haskell you have like Kerbal and Stack
and Dix and Stack and Nix together and then you have Kerbal v1, v2, new. Is there some plan to clean this up someday to give a simple way to build a Haskell project? Okay. In fact, Kerbal and Stack doesn't do exactly the same.
Stack is based on a snapshot so it's more secure if you want to have the same build for every project but both tools are compatible so Stack can use a Kerbal file so you can just write a Kerbal file, then add the version of the snapshots
you want to use for Stack and that's it. But I agree with you, there is much, many tools. I'm not familiar with Stack but I thought that Kerbal has something
like LockFire nowadays, like Freeze it's called. Is that similar to that? Sorry, Kerbal has a? Kerbal, Freeze. I don't know. Okay, I thought it's similar. I use Nix with Kerbal so there is already a Freeze with Nix but I don't use Kerbal very much so maybe, but I don't know.
Okay, thanks. Sorry. Okay, we're out of time so please, once again, thank Julian. Thank you.