Skip to content

Commit

Permalink
Update spago to v0.20.0 (#551)
Browse files Browse the repository at this point in the history
* Update to latest package set

* Update Spago to v0.20.0

* Fix Debugging folder; rename folder to Debug

* Stop CI from building everything twice

* Update module name

* Fix Spago errors/warning messages due to transitive dependency imports
  • Loading branch information
JordanMartinez committed Apr 8, 2021
1 parent 0de8de5 commit 8a6d997
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Expand Up @@ -2,9 +2,8 @@ name: CI

on:
push:
branches: [latestRelease, development]
branches: [latestRelease]
pull_request:
branches: [latestRelease, development]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion 01-Getting-Started/04-Install-Guide.md
Expand Up @@ -44,7 +44,7 @@ Unlike the manual install, `nvm` properly handles the npm prefix for you. So, yo

Once you have installed `npm`, we can use it to install everything in one command:
```bash
npm i -g purescript@0.14.0 spago@0.19.1 parcel
npm i -g purescript@0.14.0 spago@0.20.0 parcel
```

### Versions Used in this Project
Expand Down
3 changes: 3 additions & 0 deletions 21-Hello-World/02-Effect-and-Aff/spago.dhall
Expand Up @@ -10,12 +10,15 @@ You can edit this file as you like.
[ "aff"
, "console"
, "effect"
, "either"
, "js-timers"
, "node-readline"
, "now"
, "prelude"
, "psci-support"
, "random"
, "refs"
, "st"
]
, packages =
../../packages.dhall
Expand Down
9 changes: 1 addition & 8 deletions 21-Hello-World/03-Debugging/spago.dhall
Expand Up @@ -7,19 +7,12 @@ You can edit this file as you like.
, name =
"untitled"
, dependencies =
[ "aff"
, "console"
[ "console"
, "debug"
, "effect"
, "either"
, "node-readline"
, "partial"
, "prelude"
, "psci-support"
, "random"
, "refs"
, "st"
, "typelevel-prelude"
]
, packages =
../../packages.dhall
Expand Down
@@ -1,15 +1,15 @@
-- When you compile this file, it will output compiler warnings.
-- If you wish to remove that noise, comment out everything below
-- the "module" declaration.
module Debugging.DebugTrace where
module Debugging.Debug where

-- Comment out everything below this line to prevent compiler warning.
----------------------------------------------------------------------

import Prelude
import Effect (Effect)
import Effect.Console (log)
import Debug.Trace (spy, trace, traceM)
import Debug (spy, trace, traceM)

-- Given a simple Box Monad
data Box a = Box a
Expand Down
@@ -1,22 +1,22 @@
# DebugWarning

`Debug.Trace` uses Custom Type Errors to warn the developer when it is being used.
`Debug` uses Custom Type Errors to warn the developer when it is being used.

Let's examine it further since it provides an example for us to follow should we wish to do something similar in the future. The source code is [here](https://github.com/garyb/purescript-debug/blob/v4.0.0/src/Debug/Trace.purs#L8-L8), but we'll provide type signatures for the parts we need below and explain their usage:
Let's examine it further since it provides an example for us to follow should we wish to do something similar in the future. The source code is [here](https://github.com/garyb/purescript-debug/blob/v5.0.0/src/Debug.purs), but we'll provide type signatures for the parts we need below and explain their usage:
```haskell
-- See the copyright notice at the bottom of this file for this code:

-- | Nullary type class used to raise a custom warning for the debug functions.
class DebugWarning

instance warn :: Warn (Text "Debug.Trace usage") => DebugWarning
instance warn :: Warn (Text "Debug usage") => DebugWarning

foreign import trace :: forall a b. DebugWarning => a -> (Unit -> b) -> b

-- same idea as 'trace' for all the other functions
```

In short, rather than writing `function :: Warn (Text "Debug.Trace usage") => [function's type signature]` on every function, they use an empty type class whose sole instance adds this for every usage of that type class.
In short, rather than writing `function :: Warn (Text "Debug usage") => [function's type signature]` on every function, they use an empty type class whose sole instance adds this for every usage of that type class.

<hr>
Copyright notice for the above code:
Expand Down
Expand Up @@ -10,7 +10,7 @@ import Prelude

import Control.Monad.ST as ST
import Control.Monad.ST.Ref as STRef
import Debug.Trace (traceM)
import Debug (traceM)
import Effect (Effect)
import Effect.Console (log)

Expand Down
Expand Up @@ -2,9 +2,9 @@

Previously, we got around the "`bind` outputs the same box-like type it receives" restriction by using `MonadEffect`. However, we also explained that `ST`, the monad used to run a computation that uses local mutable state, did not have an instance for `MonadEffect`. This decision is intentional.

When we run production code, we want to uphold this restriction. However, when we are debugging code, this restriction can be very annoying. Fortunately, the [Debug.Trace](https://pursuit.purescript.org/packages/purescript-debug/4.0.0/docs/Debug.Trace) package exists to help you use print debugging in any monadic context. You should use it when initially prototyping things. It should never appear in production code, nor as a solution for production-level logging. (We'll show how to do that in the `Application Structure` folder).
When we run production code, we want to uphold this restriction. However, when we are debugging code, this restriction can be very annoying. Fortunately, the [Debug](https://pursuit.purescript.org/packages/purescript-debug/docs/Debug) package exists to help you use print debugging in any monadic context. You should use it when initially prototyping things. It should never appear in production code, nor as a solution for production-level logging. (We'll show how to do that in the `Application Structure` folder).

**WARNING**: `Debug.Trace`'s functions are not always reliable when running concurrent code (i.e. `Aff`-based computations).
**WARNING**: `Debug`'s functions are not always reliable when running concurrent code (i.e. `Aff`-based computations).

## Compilation Instructions

Expand All @@ -23,6 +23,6 @@ spago build

Use these commands
```bash
spago run -m Debugging.DebugTrace
spago run -m Debugging.Debug
spago run -m Debugging.LocalState
```
9 changes: 6 additions & 3 deletions 21-Hello-World/05-Application-Structure/spago.dhall
Expand Up @@ -8,18 +8,21 @@ You can edit this file as you like.
"untitled"
, dependencies =
[ "console"
, "debug"
, "effect"
, "either"
, "free"
, "functors"
, "identity"
, "maybe"
, "prelude"
, "psci-support"
, "random"
, "refs"
, "run"
, "st"
, "strings"
, "transformers"
, "tuples"
, "typelevel-prelude"
, "type-equality"
, "variant"
]
, packages =
Expand Down
13 changes: 11 additions & 2 deletions 21-Hello-World/07-Testing/spago.dhall
Expand Up @@ -7,15 +7,24 @@ You can edit this file as you like.
, name =
"untitled"
, dependencies =
[ "console"
[ "aff"
, "arrays"
, "console"
, "effect"
, "newtype"
, "enums"
, "exceptions"
, "foldable-traversable"
, "integers"
, "lists"
, "maybe"
, "partial"
, "prelude"
, "psci-support"
, "quickcheck"
, "quickcheck-laws"
, "spec"
, "strings"
, "tuples"
]
, packages =
../../packages.dhall
Expand Down
5 changes: 3 additions & 2 deletions 21-Hello-World/08-Benchmarking/spago.dhall
Expand Up @@ -7,9 +7,10 @@ You can edit this file as you like.
, name =
"ignore"
, dependencies =
[ "console"
, "prelude"
[ "prelude"
, "effect"
, "foldable-traversable"
, "newtype"
, "psci-support"
, "quickcheck"
, "benchotron"
Expand Down
2 changes: 1 addition & 1 deletion packages.dhall
@@ -1,5 +1,5 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210304/packages.dhall sha256:c88151fe7c05f05290224c9c1ae4a22905060424fb01071b691d3fe2e5bad4ca
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210406/packages.dhall sha256:7b6af643c2f61d936878f58b613fade6f3cb39f2b4a310f6095784c7b5285879

let additions =
{ benchotron =
Expand Down

0 comments on commit 8a6d997

Please sign in to comment.