Skip to content

Instantly share code, notes, and snippets.

@nixorn
Last active March 21, 2019 13:05
Show Gist options
  • Save nixorn/5c9d603d54b3729ec829b94f4fd6801e to your computer and use it in GitHub Desktop.
Save nixorn/5c9d603d54b3729ec829b94f4fd6801e to your computer and use it in GitHub Desktop.
{-# LANGUAGE LambdaCase #-}
module Main where
program = drawingOf(codeWorldLogo)
testLayout1 = l1 +1
-- Open 2 nested contexts
where l1 = l2 + l3
l2 = 2
l3 = 3 + l4
where
l4 = l5 + 7
l5 = 8
testLayout2(1) = 1 -- There should be closed both contexts
testLayout2(2) = 2
testLayout2(3) = 2 -- But actually second context closed only here
-- Multiline let expression. One context.
testLayout3 = let x = 5
y = 6
in x + y
-- Single line let expression. No contexts.
testLayout4 = let x = 4 in x + 2
-- Lambda 'case' must start layout
testLayout5 = \case
1 -> 2
2 -> 3
-- Regular 'case' must not. Instead, 'of' used with regular 'case' must
testLayout6(a) = case a of
1 -> 2
2 -> 3
-- Mixed explicit and implicit contexts
testLayout7(a) = case a of
1 -> (2, 2)
2 -> (2, case 2 + 2 of
4 -> 5
7 -> (case 5 of
5 -> 6)) -- There should be closed
testLayout8 = let a = 5
b = 6 in a + b
testLayout9 = (\l -> 40 + 2 + l)(12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment