Skip to content

Commit 5c7c1f0

Browse files
Use div-root; fix examples' warnings (#286)
* Fix compiler warnings in examples * Add div with 'root' id to support cookbook recipes * Add changelog
1 parent 866b826 commit 5c7c1f0

File tree

11 files changed

+14
-1
lines changed

11 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Bugfixes:
1212

1313
Other improvements:
1414
- Drop requirement that module name be `Main` (#285 by @JordanMartinez)
15+
- Fixes compiler warnings in examples (#286 by @JordanMartinez)
16+
- Support cookbook repo UI recipes by adding element to `frame.html` (#286 by @JordanMartinez)
1517

1618
## [v2022-07-12.1](https://github.com/purescript/trypurescript/releases/tag/v2022-07-12.1)
1719

client/examples/ADTs.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ derive instance ordName :: Ord Name
1919
phoneBook :: Map Name String
2020
phoneBook = singleton (Name "John" "Smith") "555-555-1234"
2121

22+
main :: Effect Unit
2223
main = render =<< withConsole do
2324
logShow (lookup (Name "John" "Smith") phoneBook)

client/examples/DoNotation.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Control.MonadPlus (guard)
55
import Effect.Console (logShow)
66
import Data.Array ((..))
77
import Data.Foldable (for_)
8-
import TryPureScript
8+
import TryPureScript (render, withConsole)
99

1010
-- Find Pythagorean triples using an array comprehension.
1111
triples :: Int -> Array (Array Int)
@@ -16,5 +16,6 @@ triples n = do
1616
guard $ x * x + y * y == z * z
1717
pure [x, y, z]
1818

19+
main :: Effect Unit
1920
main = render =<< withConsole do
2021
for_ (triples 20) logShow

client/examples/Generic.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ instance eqPerson :: Eq Person where
4545
instance ordPerson :: Ord Person where
4646
compare = genericCompare
4747

48+
main :: Effect Unit
4849
main = render =<< withConsole do
4950
logShow $ Person
5051
{ first: "John"

client/examples/Loops.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Data.Array ((..))
77
import Data.Foldable (for_)
88
import TryPureScript (render, withConsole)
99

10+
main :: Effect Unit
1011
main = render =<< withConsole do
1112
for_ (10 .. 1) \n -> log (show n <> "...")
1213
log "Lift off!"

client/examples/Operators.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ infixl 5 subdirectory as </>
1616
filepath :: FilePath
1717
filepath = "usr" </> "local" </> "bin"
1818

19+
main :: Effect Unit
1920
main = render =<< withConsole do
2021
log filepath

client/examples/QuickCheck.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Data.Array (sort)
55
import Test.QuickCheck (quickCheck, (===))
66
import TryPureScript (render, withConsole, h1, h2, p, text)
77

8+
main :: Effect Unit
89
main = do
910
render $ h1 $ text "QuickCheck"
1011
render $ p $ text """QuickCheck is a Haskell library which allows us to assert properties

client/examples/Records.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import Effect.Console (log)
55
import TryPureScript (render, withConsole)
66

77
-- We can write functions which require certain record labels...
8+
showPerson :: forall r. { firstName :: String, lastName :: String | r } -> String
89
showPerson o = o.lastName <> ", " <> o.firstName
910

1011
-- ... but we are free to call those functions with any
1112
-- additional arguments, such as "age" here.
13+
main :: Effect Unit
1214
main = render =<< withConsole do
1315
log $ showPerson
1416
{ firstName: "John"

client/examples/Recursion.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ isEven :: Int -> Boolean
1212
isEven 0 = true
1313
isEven n = isOdd (n - 1)
1414

15+
main :: Effect Unit
1516
main = render =<< withConsole do
1617
logShow $ isEven 1000
1718
logShow $ isEven 1001

client/examples/TypeClasses.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ printf = printfWith ""
3939
debug :: String -> Int -> String -> String
4040
debug uri status msg = printf "[" uri "] " status ": " msg
4141

42+
main :: Effect Unit
4243
main = render =<< withConsole do
4344
log $ debug "http://www.purescript.org" 200 "OK"
4445
log $ debug "http://bad.purescript.org" 404 "Not found"

client/public/frame.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
</head>
4848
<body>
4949
<main id="main"></main>
50+
<div id="root"></div>
5051
</body>
5152
</html>

0 commit comments

Comments
 (0)