Skip to content

Loading…

Bunch of README fixes, and addition of the "Multi-line output" section #87

Merged
merged 6 commits into from

2 participants

@orlitzky

I think each commit should be self-explanatory! I left the broken example broken, since it's broken. But it should be expecting "6" as output like in the working example.

@sol sol merged commit 9a8f50e into sol:master
@sol
Owner

Awesome, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 41 additions and 6 deletions.
  1. +41 −6 README.markdown
View
47 README.markdown
@@ -102,7 +102,7 @@ Here is an example:
```haskell
module Foo where
-- $setup
--- >>> let x = 23
+-- >>> let x = 23 :: Int
-- |
-- >>> foo + x
@@ -137,16 +137,16 @@ perspective. A workaround is to avoid leading space, or add a newline such
that the indentation does not matter:
```haskell
-{- | >>> {:
+{- | >>> :{
let x = 1
y = 2
in x + y + works
:}
-3
+6
-}
works = 3
-{- | >>> {:
+{- | >>> :{
let x = 1
y = 2
in x + y + broken
@@ -156,6 +156,41 @@ works = 3
broken = 3
```
+### Multi-line output
+If there are no blank lines in the output, multiple lines are handled
+automatically.
+
+```haskell
+-- | >>> putStr "Hello\nWorld!"
+-- Hello
+-- World!
+```
+
+If however the output contains blank lines, they must be noted
+explicitly with `<BLANKLINE>`. For example,
+
+```haskell
+import Data.List ( intercalate )
+
+-- | Double-space a paragraph.
+--
+-- Examples:
+--
+-- >>> let s1 = "\"Every one of whom?\""
+-- >>> let s2 = "\"Every one of whom do you think?\""
+-- >>> let s3 = "\"I haven't any idea.\""
+-- >>> let paragraph = unlines [s1,s2,s3]
+-- >>> putStrLn $ doubleSpace paragraph
+-- "Every one of whom?"
+-- <BLANKLINE>
+-- "Every one of whom do you think?"
+-- <BLANKLINE>
+-- "I haven't any idea."
+--
+doubleSpace :: String -> String
+doubleSpace = (intercalate "\n\n") . lines
+```
+
### QuickCheck properties
Haddock (since version 2.13.0) has markup support for properties. Doctest can
@@ -238,7 +273,7 @@ There are three ways to deal with this:
-- >>> xpto "what?"
-- "what?:xpto!"
xpto :: Text -> Text
- xpto = (<> ":xtpo!")
+ xpto = (<> ":xpto!")
```
3. Putting it into a ```$setup``` hook
@@ -254,7 +289,7 @@ There are three ways to deal with this:
-- >>> xpto "what?"
-- "what?:xpto!"
xpto :: Text -> Text
- xpto = (<> ":xtpo!")
+ xpto = (<> ":xpto!")
```
Note that a ```$setup``` hook is also a named chunk,
Something went wrong with that request. Please try again.