SYS:// haskell.quest
00:00:00 ONLINE
// MISSION_BRIEFING.lhs

HASKELL QUEST

A neon-lit data realm where lambdas hunt monads and types are pure.

You are operative QX-7741. Your mission, should you choose to compile it: traverse 42 quests across the algebraic frontier, unlock the IO sectors, and bind the Maybe nebula.

00QUESTS
0000OPERATIVES
0000COMPILES
00% PURE
// SECTOR_02

QUEST GRID

Hexagonal sectors of the algebraic frontier. Hover a node to read intel; click to deploy.

// COMPLETE // ACTIVE // LOCKED
// SECTOR_03

HOLOGRAPHIC TERMINAL

Live challenge harness. Stream input on the left, compile output on the right.

// CHALLENGE_07.txt

> Quest 07 // The Maybe Nebula

Implement safeDiv :: Int -> Int -> Maybe Int such that a division by zero returns Nothing and any other input returns Just the quotient. Bind it through >>= for triple chained division.

// constraints

  • no error, no undefined
  • total function, pure
  • must compile under -Wall

// hints

Reach for do-notation only after the kleisli arrow stops smiling at you.

// editor.hs READY
module Quest07 where

safeDiv :: Int -> Int -> Maybe Int
safeDiv _ 0 = Nothing
safeDiv x y = Just (x `div` y)

chain :: Int -> Int -> Int -> Maybe Int
chain a b c =
  safeDiv a b >>= \r ->
  safeDiv r c

main :: IO ()
main = print (chain 144 12 2)

// stdout will materialize here

// SECTOR_04

OPERATIVE LEADERBOARD

Top compilers in the algebraic frontier. Updated every cycle.

RANK OPERATIVE SECTOR QUESTS SCORE
01monad.witchIO/Maybe4299,420
02lambda_driftFunctor4192,108
03kleisli_kidArrow4088,776
04foldr_phantomList3881,202
05typevar_tHKT3778,944
06purefn_77Lambda3674,610
07nullable.ioMaybe3470,005
08applicative_xApplicative3366,318
09traverse_vTraversable3161,777
10QX-7741YOU0714,210