liveBook · Manning

Just

As explained in Learn Haskell by Example

Just is the Maybe constructor that contains a value of a parameterized type.

Just is the Maybe constructor that wraps a value of a parameterized type. A Maybe value is either Just a value or Nothing, allowing a function to represent failure or an optional result without crashing. section 3.3.2

Wrapping a parsed file path

A parser can return Just filePath when it receives one argument and Nothing otherwise: parseArguments [filePath] = Just filePath; parseArguments _ = Nothing. The result type is Maybe FilePath. section 3.3.2

Handle Just values through pattern matching and related Maybe operations:

  • Match Just v to extract the wrapped value, and handle Nothing separately or provide a default. section 3.3.2
  • Use fromMaybe to return the wrapped value or a fallback, such as fromMaybe 0 (Just 100) producing 100. section 3.3.2
  • Pass Just or Nothing through a higher-order update function to add, update, or delete associative-list mappings. section 5.2
data Maybe a = Just a | Nothing

Inspect the definition data Maybe a = Just a | Nothing to see how Just carries a value while Nothing carries no further information. section 3.3.2

How Learn Haskell by Example covers it

How deep it goes
Explains the constructor, pattern matching, defaults, and update behavior, but does not descend into deeper typeclass machinery.
Examples
Uses file-path parsing, fromMaybe defaults, and associative-list insertion, replacement, or deletion.
What it assumes
Assumes basic Haskell functions and types while introducing algebraic data types, constructors, and parameterized Maybe values.
What you can do after
Apply pattern matching and Maybe functions to consume wrapped values without treating missing results as crashes.
How it connects
Connects Just with Maybe, Nothing, pattern matching, higher-order functions, and immutable data structures.

Also explained in

Compare how 2 books explain Just →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.