Skip to content

Commit

Permalink
Use div-root; fix examples' warnings (#286)
Browse files Browse the repository at this point in the history
* Fix compiler warnings in examples

* Add div with 'root' id to support cookbook recipes

* Add changelog
  • Loading branch information
JordanMartinez authored Jul 15, 2022
1 parent 866b826 commit 5c7c1f0
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Bugfixes:

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

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

Expand Down
1 change: 1 addition & 0 deletions client/examples/ADTs.purs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ derive instance ordName :: Ord Name
phoneBook :: Map Name String
phoneBook = singleton (Name "John" "Smith") "555-555-1234"

main :: Effect Unit
main = render =<< withConsole do
logShow (lookup (Name "John" "Smith") phoneBook)
3 changes: 2 additions & 1 deletion client/examples/DoNotation.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Control.MonadPlus (guard)
import Effect.Console (logShow)
import Data.Array ((..))
import Data.Foldable (for_)
import TryPureScript
import TryPureScript (render, withConsole)

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

main :: Effect Unit
main = render =<< withConsole do
for_ (triples 20) logShow
1 change: 1 addition & 0 deletions client/examples/Generic.purs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ instance eqPerson :: Eq Person where
instance ordPerson :: Ord Person where
compare = genericCompare

main :: Effect Unit
main = render =<< withConsole do
logShow $ Person
{ first: "John"
Expand Down
1 change: 1 addition & 0 deletions client/examples/Loops.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Data.Array ((..))
import Data.Foldable (for_)
import TryPureScript (render, withConsole)

main :: Effect Unit
main = render =<< withConsole do
for_ (10 .. 1) \n -> log (show n <> "...")
log "Lift off!"
1 change: 1 addition & 0 deletions client/examples/Operators.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ infixl 5 subdirectory as </>
filepath :: FilePath
filepath = "usr" </> "local" </> "bin"

main :: Effect Unit
main = render =<< withConsole do
log filepath
1 change: 1 addition & 0 deletions client/examples/QuickCheck.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Data.Array (sort)
import Test.QuickCheck (quickCheck, (===))
import TryPureScript (render, withConsole, h1, h2, p, text)

main :: Effect Unit
main = do
render $ h1 $ text "QuickCheck"
render $ p $ text """QuickCheck is a Haskell library which allows us to assert properties
Expand Down
2 changes: 2 additions & 0 deletions client/examples/Records.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import Effect.Console (log)
import TryPureScript (render, withConsole)

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

-- ... but we are free to call those functions with any
-- additional arguments, such as "age" here.
main :: Effect Unit
main = render =<< withConsole do
log $ showPerson
{ firstName: "John"
Expand Down
1 change: 1 addition & 0 deletions client/examples/Recursion.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ isEven :: Int -> Boolean
isEven 0 = true
isEven n = isOdd (n - 1)

main :: Effect Unit
main = render =<< withConsole do
logShow $ isEven 1000
logShow $ isEven 1001
1 change: 1 addition & 0 deletions client/examples/TypeClasses.purs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ printf = printfWith ""
debug :: String -> Int -> String -> String
debug uri status msg = printf "[" uri "] " status ": " msg

main :: Effect Unit
main = render =<< withConsole do
log $ debug "http://www.purescript.org" 200 "OK"
log $ debug "http://bad.purescript.org" 404 "Not found"
1 change: 1 addition & 0 deletions client/public/frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
</head>
<body>
<main id="main"></main>
<div id="root"></div>
</body>
</html>

0 comments on commit 5c7c1f0

Please sign in to comment.