git.iko.soy/rowtype-yoga/purescript-next-website-commons
on main help sign in
WIP
34a39e3sigma-andex
.gitignorenew file+10
unifiedsplit
@@ -0,0 +1,10 @@
1+/bower_components/
2+/node_modules/
3+/.pulp-cache/
4+/output/
5+/generated-docs/
6+/.psc-package/
7+/.psc*
8+/.purs*
9+/.psa*
10+/.spago
package.jsonnew file+12
@@ -0,0 +1,12 @@
1+{
2+ "name": "purescript-next-website-commons",
3+ "version": "1.0.0",
4+ "description": "",
5+ "main": "index.js",
6+ "scripts": {
7+ "test": "echo \"Error: no test specified\" && exit 1"
8+ },
9+ "keywords": [],
10+ "author": "",
11+ "license": "ISC"
12+}
packages.dhallnew file+105
@@ -0,0 +1,105 @@
1+{-
2+Welcome to your new Dhall package-set!
3+
4+Below are instructions for how to edit this file for most use
5+cases, so that you don't need to know Dhall to use it.
6+
7+## Use Cases
8+
9+Most will want to do one or both of these options:
10+1. Override/Patch a package's dependency
11+2. Add a package not already in the default package set
12+
13+This file will continue to work whether you use one or both options.
14+Instructions for each option are explained below.
15+
16+### Overriding/Patching a package
17+
18+Purpose:
19+- Change a package's dependency to a newer/older release than the
20+ default package set's release
21+- Use your own modified version of some dependency that may
22+ include new API, changed API, removed API by
23+ using your custom git repo of the library rather than
24+ the package set's repo
25+
26+Syntax:
27+where `entityName` is one of the following:
28+- dependencies
29+- repo
30+- version
31+-------------------------------
32+let upstream = --
33+in upstream
34+ with packageName.entityName = "new value"
35+-------------------------------
36+
37+Example:
38+-------------------------------
39+let upstream = --
40+in upstream
41+ with halogen.version = "master"
42+ with halogen.repo = "https://example.com/path/to/git/repo.git"
43+
44+ with halogen-vdom.version = "v4.0.0"
45+ with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
46+-------------------------------
47+
48+### Additions
49+
50+Purpose:
51+- Add packages that aren't already included in the default package set
52+
53+Syntax:
54+where `<version>` is:
55+- a tag (i.e. "v4.0.0")
56+- a branch (i.e. "master")
57+- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
58+-------------------------------
59+let upstream = --
60+in upstream
61+ with new-package-name =
62+ { dependencies =
63+ [ "dependency1"
64+ , "dependency2"
65+ ]
66+ , repo =
67+ "https://example.com/path/to/git/repo.git"
68+ , version =
69+ "<version>"
70+ }
71+-------------------------------
72+
73+Example:
74+-------------------------------
75+let upstream = --
76+in upstream
77+ with benchotron =
78+ { dependencies =
79+ [ "arrays"
80+ , "exists"
81+ , "profunctor"
82+ , "strings"
83+ , "quickcheck"
84+ , "lcg"
85+ , "transformers"
86+ , "foldable-traversable"
87+ , "exceptions"
88+ , "node-fs"
89+ , "node-buffer"
90+ , "node-readline"
91+ , "datetime"
92+ , "now"
93+ ]
94+ , repo =
95+ "https://github.com/hdgarrood/purescript-benchotron.git"
96+ , version =
97+ "v7.0.0"
98+ }
99+-------------------------------
100+-}
101+let upstream =
102+ https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230118/packages.dhall
103+ sha256:973809c5d08a285ac10c6e66be04ca2c85a2d26493644e9196a6a411359f84b9
104+
105+in upstream
spago.dhallnew file+27
@@ -0,0 +1,27 @@
1+{-
2+Welcome to a Spago project!
3+You can edit this file as you like.
4+
5+Need help? See the following resources:
6+- Spago documentation: https://github.com/purescript/spago
7+- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
8+
9+When creating a new Spago project, you can use
10+`spago init --no-comments` or `spago init -C`
11+to generate this file without the comments in this block.
12+-}
13+{ name = "my-project"
14+, dependencies =
15+ [ "console"
16+ , "effect"
17+ , "either"
18+ , "foreign"
19+ , "maybe"
20+ , "prelude"
21+ , "record-studio"
22+ , "transformers"
23+ , "yoga-json"
24+ ]
25+, packages = ./packages.dhall
26+, sources = [ "src/**/*.purs", "test/**/*.purs" ]
27+}
src/Commons.pursnew file+62
@@ -0,0 +1,62 @@
1+module Commons where
2+
3+import Prelude
4+
5+import Control.Monad.Except (except)
6+import Data.Either (Either(..))
7+import Data.Eq.Generic (genericEq)
8+import Data.Generic.Rep (class Generic)
9+import Data.Maybe (Maybe)
10+import Data.Show.Generic (genericShow)
11+import Foreign (ForeignError(..))
12+import Record.Studio ((//))
13+import Yoga.JSON (class ReadForeign, class WriteForeign, writeImpl)
14+import Yoga.JSON as YogaJson
15+
16+type Props =
17+ { header :: String
18+ , baseUrl :: String
19+ }
20+
21+type DeclarationR =
22+ ( module :: String
23+ , title :: String
24+ , typeOrValue :: String
25+ , typeText :: Maybe String
26+ )
27+
28+type PackageR = (deprecated :: Boolean)
29+
30+type ModuleR = (module :: String)
31+
32+data SearchInfo = Declaration { | DeclarationR } | Package { | PackageR } | Module { | ModuleR }
33+
34+derive instance Generic SearchInfo _
35+instance Eq SearchInfo where
36+ eq = genericEq
37+
38+instance Show SearchInfo where
39+ show = genericShow
40+
41+instance ReadForeign SearchInfo where
42+ readImpl f = do
43+ { "type": t } :: { "type" :: String } <- YogaJson.readImpl f
44+ case t of
45+ "declaration" -> YogaJson.readImpl f <#> Declaration
46+ "package" -> YogaJson.readImpl f <#> Package
47+ "module" -> YogaJson.readImpl f <#> Module
48+ other -> except $ Left (pure $ ForeignError $ "Invalid search info type " <> other)
49+
50+instance WriteForeign SearchInfo where
51+ writeImpl (Declaration r) = writeImpl $ { "type": "declaration" } // r
52+ writeImpl (Package p) = writeImpl $ { "type": "package" } // p
53+ writeImpl (Module m) = writeImpl $ { "type": "module" } // m
54+
55+type SearchResult =
56+ { info :: SearchInfo
57+ , markup :: String
58+ , package :: String
59+ , text :: String
60+ , version :: String
61+ }
62+
test/Main.pursnew file+11
@@ -0,0 +1,11 @@
1+module Test.Main where
2+
3+import Prelude
4+
5+import Effect (Effect)
6+import Effect.Class.Console (log)
7+
8+main :: Effect Unit
9+main = do
10+ log "🍝"
11+ log "You should add some tests."