From ce7c44cee6bb9de1896105d9c92f1b4d5be3a617 Mon Sep 17 00:00:00 2001 From: flip111 Date: Sat, 29 Jan 2022 16:50:26 +0100 Subject: [PATCH 1/2] Add spago files --- .gitignore | 7 ++++ packages.dhall | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ spago.dhall | 28 +++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 packages.dhall create mode 100644 spago.dhall diff --git a/.gitignore b/.gitignore index 307f9c0..f9047c0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,10 @@ /bower_components/ /node_modules/ /output/ +/.pulp-cache/ +/generated-docs/ +/.psc-package/ +/.psc* +/.purs* +/.psa* +/.spago \ No newline at end of file diff --git a/packages.dhall b/packages.dhall new file mode 100644 index 0000000..4df38ef --- /dev/null +++ b/packages.dhall @@ -0,0 +1,104 @@ +{- +Welcome to your new Dhall package-set! + +Below are instructions for how to edit this file for most use +cases, so that you don't need to know Dhall to use it. + +## Use Cases + +Most will want to do one or both of these options: +1. Override/Patch a package's dependency +2. Add a package not already in the default package set + +This file will continue to work whether you use one or both options. +Instructions for each option are explained below. + +### Overriding/Patching a package + +Purpose: +- Change a package's dependency to a newer/older release than the + default package set's release +- Use your own modified version of some dependency that may + include new API, changed API, removed API by + using your custom git repo of the library rather than + the package set's repo + +Syntax: +where `entityName` is one of the following: +- dependencies +- repo +- version +------------------------------- +let upstream = -- +in upstream + with packageName.entityName = "new value" +------------------------------- + +Example: +------------------------------- +let upstream = -- +in upstream + with halogen.version = "master" + with halogen.repo = "https://example.com/path/to/git/repo.git" + + with halogen-vdom.version = "v4.0.0" + with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies +------------------------------- + +### Additions + +Purpose: +- Add packages that aren't already included in the default package set + +Syntax: +where `` is: +- a tag (i.e. "v4.0.0") +- a branch (i.e. "master") +- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977") +------------------------------- +let upstream = -- +in upstream + with new-package-name = + { dependencies = + [ "dependency1" + , "dependency2" + ] + , repo = + "https://example.com/path/to/git/repo.git" + , version = + "" + } +------------------------------- + +Example: +------------------------------- +let upstream = -- +in upstream + with benchotron = + { dependencies = + [ "arrays" + , "exists" + , "profunctor" + , "strings" + , "quickcheck" + , "lcg" + , "transformers" + , "foldable-traversable" + , "exceptions" + , "node-fs" + , "node-buffer" + , "node-readline" + , "datetime" + , "now" + ] + , repo = + "https://github.com/hdgarrood/purescript-benchotron.git" + , version = + "v7.0.0" + } +------------------------------- +-} +let upstream = + https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20220127/packages.dhall sha256:8ccbd53dbc7dbfd92a9cba9cca7a8bf36cb120a0a3e21106bf19a16d3ad6863e + +in upstream diff --git a/spago.dhall b/spago.dhall new file mode 100644 index 0000000..1e117fb --- /dev/null +++ b/spago.dhall @@ -0,0 +1,28 @@ +{- +Welcome to a Spago project! +You can edit this file as you like. + +Need help? See the following resources: +- Spago documentation: https://github.com/purescript/spago +- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html + +When creating a new Spago project, you can use +`spago init --no-comments` or `spago init -C` +to generate this file without the comments in this block. +-} +{ name = "halogen-vdom-string-renderer" +, dependencies = + [ "arrays" + , "foreign" + , "halogen-vdom" + , "maybe" + , "ordered-collections" + , "prelude" + , "psci-support" + , "strings" + , "tuples" + , "unsafe-coerce" + ] +, packages = ./packages.dhall +, sources = [ "src/**/*.purs" ] +} From 61e1d5d91880f60bf79ecf86c11f99e1c3b9c1e5 Mon Sep 17 00:00:00 2001 From: flip111 Date: Sun, 30 Jan 2022 01:15:58 +0100 Subject: [PATCH 2/2] Fix bug in conversion from Number to String --- spago.dhall | 1 + src/Halogen/VDom/DOM/StringRenderer.purs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spago.dhall b/spago.dhall index 1e117fb..37ac07b 100644 --- a/spago.dhall +++ b/spago.dhall @@ -16,6 +16,7 @@ to generate this file without the comments in this block. , "foreign" , "halogen-vdom" , "maybe" + , "numbers" , "ordered-collections" , "prelude" , "psci-support" diff --git a/src/Halogen/VDom/DOM/StringRenderer.purs b/src/Halogen/VDom/DOM/StringRenderer.purs index 37223c7..8924f85 100644 --- a/src/Halogen/VDom/DOM/StringRenderer.purs +++ b/src/Halogen/VDom/DOM/StringRenderer.purs @@ -1,16 +1,18 @@ module Halogen.VDom.DOM.StringRenderer (render) where -import Prelude -import Halogen.VDom (VDom, ElemName(..)) -import Halogen.VDom.DOM.Prop (Prop(..), PropValue) import Data.Array as A -import Foreign (unsafeToForeign, typeOf) import Data.Maybe (Maybe(..)) -import Data.String as S +import Data.Number.Format import Data.Set as Set +import Data.String as S +import Foreign (unsafeToForeign, typeOf) +import Halogen.VDom (VDom, ElemName(..)) +import Halogen.VDom.DOM.Prop (Prop(..), PropValue) import Halogen.VDom.StringRenderer as VSR import Halogen.VDom.StringRenderer.Util (escape) +import Prelude import Unsafe.Coerce (unsafeCoerce) +import Data.Number.Format (toString) render ∷ ∀ i w. (w → String) → VDom (Array (Prop i)) w → String render renderWidget = VSR.render getTagType renderProps renderWidget @@ -42,7 +44,7 @@ propNameToAttrName = case _ of renderProperty ∷ String → PropValue → Maybe String renderProperty name prop = case typeOf (unsafeToForeign prop) of "string" → renderAttr name' $ (unsafeCoerce ∷ PropValue → String) prop - "number" → renderAttr name' $ show ((unsafeCoerce ∷ PropValue → String) prop) + "number" → renderAttr name' $ toString ((unsafeCoerce ∷ PropValue → Number) prop) "boolean" → Just $ escape name' _ → Nothing where