on master help sign in
Merge branch 'remote_import' of github.com:agentm/project-m36 into remote_import

# Conflicts: # project-m36.cabal

commit68a16781a3f157001184446ae5d4325b13028227 authorA.M <agentm@themactionfaction.com> dateSat 3 Apr 2021, 22:10 (6 years ago) parent2140de973bfbb9
8 files changed+39−57
Changelog.markdown+4 docs/tutd_cheatsheet.markdown+2 docs/tutd_tutorial.markdown+18 project-m36.cabal+4−3 src/bin/TutorialD/Interpreter/Import/TutorialD.hs+5−6 stack.ghc8.0.yaml−48 stack.ghc8.6.yaml+4 stack.ghc8.8.yaml+2
Changelog.markdown+4
@@ -1,3 +1,7 @@
1+# 2021-04-01 (v0.9.3)
2+
3+* add new ":importtutd <URI> <SHA256 hash>" feature to import TutorialD from a local file or a HTTP/HTTPS URI
4+
15# 2020-12-27 (v0.9.0)
26
37* replace unmaintained distributed-process-client-server RPC package with new curryer RPC package
docs/tutd_cheatsheet.markdown+2
@@ -48,6 +48,8 @@ Database context expressions take the current database context as input and alte
4848|Database Context Expression |Description |
4949|------------------------------------------------------|---------------------------------------|
5050|`:importexample cjdate`|Imports a precooked schema from Chris Date's books resulting in relvars `s`, `sp`, and `p`|
51+|`:importtutd "file:///home/agentm/project-m36/scripts/emp.tutd"`|Imports TutorialD from file URI|
52+|`:importtutd "https://raw.githubusercontent.com/agentm/project-m36/master/scripts/emp.tutd" "effe32b247586dc3ac0079fc241b9618d41d189afcaeb7907edbe5a8b45992a4"`| Imports TutorialD from HTTP or HTTPS URI|
5153|`newrelvar:=relation{tuple{age 3}}`|Assign a new relation variable named `newrelvar`|
5254|`undefine s`|Remove a relation variable|
5355|`insert s relation{tuple{city "Boston",s# "S10",sname "Gonzalez",status 10}}`| Append to an existing relation variable with another relational expression|
docs/tutd_tutorial.markdown+18
@@ -30,6 +30,24 @@ Each section assumes a fresh instance of the Date examples. The relation variabl
3030|p|parts|
3131|sp|contains mapping of which suppliers supply which parts|
3232
33+### Importing TutorialD from Other Sources
34+
35+The `tutd` console can also run TutorialD from a local file or from a web server.
36+
37+To import TutorialD from a file:
38+
39+```
40+:importtutd "file:///home/agentm/project-m36/scripts/emp.tutd"
41+```
42+
43+or from a web server:
44+
45+```
46+:importtutd "https://raw.githubusercontent.com/agentm/project-m36/master/scripts/DateExamples.tutd" "db9f3d9fe06d0a29b8355e045b89ec94d6428e3a3de93def7ca77bf0298b7010"
47+```
48+
49+The second argument is an optional SHA256 hash in hexadecimal form. This can be used to validate that the script has not changed since the last import. Importing TutorialD from the web is in general safe because it is effectively sandboxed with "Safe Haskell" for functions, so the script is contained security-wise, however, nothing prevents the script from running forever. Downloading a schema from the web is a great way to share schemas and to kick start your project without starting from scratch.
50+
3351### Types
3452
3553TutorialD is strongly-typed. The basic built-in types are:
project-m36.cabal+4−3
@@ -1,6 +1,6 @@
11Cabal-Version: 2.2
22Name: project-m36
3−Version: 0.9.2
3+Version: 0.9.3
44License: MIT
55--note that this license specification is erroneous and only labeled MIT to appease hackage which does not recognize public domain packages in cabal >2.2- Project:M36 is dedicated to the public domain
66Build-Type: Simple
@@ -35,7 +35,7 @@ Flag haskell-scripting
3535 Default: True
3636
3737Library
38− Build-Depends: base>=4.8 && < 4.15, ghc-paths, mtl, containers, unordered-containers, hashable, haskeline, directory, MonadRandom, random-shuffle, uuid >= 1.3.12, cassava >= 0.4.5.1 && < 0.6, text, bytestring, deepseq, deepseq-generics, vector, parallel, monad-parallel, exceptions, transformers, gnuplot, filepath, zlib, directory, temporary, stm, time, hashable-time, old-locale, rset, attoparsec, either, base64-bytestring, data-interval, extended-reals, aeson >= 1.1, path-pieces, conduit, resourcet, http-api-data, semigroups, QuickCheck, quickcheck-instances, list-t, stm-containers >= 0.2.15, foldl, optparse-applicative, Glob, cryptohash-sha256, text-manipulate >= 0.2.0.1 && < 0.4, winery, curryer-rpc, network, async, vector-instances, recursion-schemes
38+ Build-Depends: base>=4.8 && < 4.15, ghc-paths, mtl, containers, unordered-containers, hashable, haskeline, directory, MonadRandom, random-shuffle, uuid >= 1.3.12, cassava >= 0.4.5.1 && < 0.6, text, bytestring, deepseq, deepseq-generics, vector, parallel, monad-parallel, exceptions, transformers, gnuplot, filepath, zlib, directory, temporary, stm, time, hashable-time, old-locale, rset, attoparsec, either, base64-bytestring, data-interval, extended-reals, aeson >= 1.1, path-pieces, conduit, resourcet, http-api-data, semigroups, QuickCheck, quickcheck-instances, list-t, stm-containers >= 0.2.15, foldl, optparse-applicative, Glob, cryptohash-sha256, text-manipulate >= 0.2.0.1 && < 0.4, winery, curryer-rpc, network, async, vector-instances, recursion-schemes, streamly >= 0.7.2
3939 if flag(haskell-scripting)
4040 Build-Depends: ghc >= 8.2 && < 8.11
4141 CPP-Options: -DPM36_HASKELL_SCRIPTING
@@ -186,7 +186,8 @@ Executable tutd
186186 curryer-rpc,
187187 prettyprinter,
188188 cryptohash-sha256,
189− base16-bytestring,
189+ --due to decode signature change
190+ base16-bytestring >= 1.0.0.0,
190191 http-conduit,
191192 modern-uri,
192193 http-types
src/bin/TutorialD/Interpreter/Import/TutorialD.hs+5−6
@@ -78,10 +78,9 @@ tutdImportP = do
7878 uri <- quoted URI.parser
7979 spaceConsumer
8080 mhash <- optional (quoted hex)
81− let handler =
82− case URI.unRText <$> URI.uriScheme uri of
83− Nothing -> fail "URI scheme missing"
84− Just "file" -> importTutorialDFromFile
85− Just scheme | scheme `elem` ["http", "https"] -> importTutorialDViaHTTP
86− | otherwise -> fail ("unsupported URI scheme: " <> show scheme)
81+ handler <- case URI.unRText <$> URI.uriScheme uri of
82+ Nothing -> fail "URI scheme missing"
83+ Just "file" -> pure importTutorialDFromFile
84+ Just scheme | scheme `elem` ["http", "https"] -> pure importTutorialDViaHTTP
85+ | otherwise -> fail ( "unsupported URI scheme: " <> show scheme)
8786 pure $ DatabaseContextDataImportOperator uri mhash handler
stack.ghc8.0.yamldeleted−48
@@ -1,48 +0,0 @@
1−# This file was automatically generated by stack init
2−# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/
3−
4−# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
5−resolver: lts-8.5
6−
7−# Local packages, usually specified by relative directory name
8−packages:
9−- '.'
10−# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
11−extra-deps:
12−- git: https://github.com/agentm/curryer.git
13− commit: 1e60c0580ca33d6ae1e97aaddc32189fdfe3ef6c
14−- data-accessor-transformers-0.2.1.7
15−- data-interval-1.2.0
16−- extended-reals-0.2.1.0
17−- gnuplot-0.5.4.1
18−- text-1.2.2.1
19−- aeson-1.2.1.00
20−- deferred-folds-0.6.12
21−- rset-1.0.0
22−
23−# Override default flag values for local packages and extra-deps
24−flags: {}
25−
26−# Extra package databases containing global packages
27−extra-package-dbs: []
28−
29−# Control whether we use the GHC we find on the path
30−# system-ghc: true
31−
32−# Require a specific version of stack, using version ranges
33−# require-stack-version: -any # Default
34−# require-stack-version: >= 1.0.0
35−
36−# Override the architecture used by stack, especially useful on Windows
37−# arch: i386
38−# arch: x86_64
39−
40−# Extra directories used by stack for building
41−# extra-include-dirs: [/path/to/dir]
42−# extra-lib-dirs: [/path/to/dir]
43−
44−# Allow a newer minor version of GHC than the snapshot specifies
45−# compiler-check: newer-minor
46−
47−allow-newer: true
48−
stack.ghc8.6.yaml+4
@@ -28,6 +28,10 @@ extra-deps:
2828- prettyprinter-1.7.0
2929- prettyprinter-ansi-terminal-1.1.2
3030- fusion-plugin-types-0.1.0
31+- base16-bytestring-1.0.1.0
32+- modern-uri-0.3.4.0
33+- cryptohash-sha256-0.11.102.0
34+- http-types-0.12.3
3135
3236# Override default flag values for local packages and extra-deps
3337flags:
stack.ghc8.8.yaml+2
@@ -30,6 +30,8 @@ extra-deps:
3030- primitive-unlifted-0.1.3.0
3131- prettyprinter-1.7.0
3232- prettyprinter-ansi-terminal-1.1.2
33+- base16-bytestring-1.0.1.0
34+- modern-uri-0.3.4.0
3335
3436# Override default flag values for local packages and extra-deps
3537flags: