HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to HaskellVariables (let)Data TypesOperatorsStringsListsConditions (if / then / else)Iteration (map / sum)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Value & Type
🔢 Numbers & Math
✍️ String
📚 List
🔀 Condition
🧩 Function
Function definitionLambda ( \ )
Haskell›REFERENCE›Function
🧩

Function

Definition, type signature, and lambda.

CommandDescription
Function definitionDefining your own function.
Lambda ( \ )Nameless (anonymous) function.

Function definition

Try it yourself →

Defining your own function.

Syntax

name :: Type -> Type\nname param = expression

Description

Functions are written as 'name parameter = expression'; a type signature (::) is placed above. Calls are without parentheses, and arguments are separated by spaces.

Example

addUp :: Int -> Int -> Int
addUp a b = a + b
main = print (addUp 8 9)

Expected output

17

When to use?

Preventing code repetition, breaking the program into parts.

Common mistakes

  • ⚠️ Calls are without parentheses: addUp 8 9 (not addUp(8,9)).

Lambda ( \ )

Try it yourself →

Nameless (anonymous) function.

Syntax

\x -> expression

Description

An anonymous function is written in the form \x -> expression. Usually passed as an argument to places like map/filter.

Example

main = print (map (\x -> x + 1) [1, 2, 3])

Expected output

[2,3,4]

When to use?

map/filter callbacks, short utility functions.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code