{"id":15017918,"url":"https://github.com/sjbiaga/pisc-dotarrow","last_synced_at":"2026-03-16T21:05:37.583Z","repository":{"id":242713482,"uuid":"810250565","full_name":"sjbiaga/pisc-dotarrow","owner":"sjbiaga","description":"DotArrow is the codename for \"mobile code\" in the context of a Pi-calculus to Scala translator ","archived":false,"fork":false,"pushed_at":"2024-07-17T14:49:08.000Z","size":165,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T17:34:13.188Z","etag":null,"topics":["haskell","metaprogramming","mobile-code","perl-script","pi-calculus","scala","scalameta","shell-scripts","template-haskell"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sjbiaga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-04T10:37:19.000Z","updated_at":"2024-07-17T14:49:12.000Z","dependencies_parsed_at":"2024-07-17T18:16:00.074Z","dependency_job_id":null,"html_url":"https://github.com/sjbiaga/pisc-dotarrow","commit_stats":null,"previous_names":["sjbiaga/pisc-dotarrow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjbiaga%2Fpisc-dotarrow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjbiaga%2Fpisc-dotarrow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjbiaga%2Fpisc-dotarrow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjbiaga%2Fpisc-dotarrow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjbiaga","download_url":"https://codeload.github.com/sjbiaga/pisc-dotarrow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243318751,"owners_count":20272137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","metaprogramming","mobile-code","perl-script","pi-calculus","scala","scalameta","shell-scripts","template-haskell"],"created_at":"2024-09-24T19:51:10.453Z","updated_at":"2025-12-28T01:14:26.061Z","avatar_url":"https://github.com/sjbiaga.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"DotArrow\n========\n\n`DotArrow` is the codename for \"_mobile code_\" in the context of a `Pi-calculus` to\n`Scala` translator. It is implemented in a very simplistic fashion, for either\n `Scala` or `Haskell`.\n\n\nDotArrow - `Scala`\n------------------\n\nIt is possible for `Scala` in [`PISC`](https://github.com/sjbiaga/pisc) because\nof three reasons:\n\n- input actions allow for the received value to be applied a function before returning\n  the actual result - so that an entire `Scala` source file passed as a `String` can be\n  updated through `scala.sys.process._` facility to one modified as follows;\n\n- the `IO` monad in the \"mobile code\" allows for a sequence of `flatMap`s to be chained\n  and - if wanted - to be `IO.canceled` at any point between two `flatMap`s;\n\n- [`Scalameta`](https://scalameta.org) allows for `Enumerator.Generator`s to be\n  manipulated such that `IO.canceled` is inserted after each `flatMap` with a\n  pattern variable with ascribed type.\n\nAlso, `Serializable` (`case`) `class`es allow for objects of type other than basic\ntypes to be read and written using `ObjectInputStream` and `ObjectOutputStream`.\n\nAlternatively, objects can be encoded to/decoded from `JSON` using the `Scala` library\n[circe](https://circe.github.io/circe/).\n\nThe `bin/pi.sh` shell script has been added, respectively, two functions:\n\n- `dotarrowCirce` and `dotarrowCirce2`;\n- `dotarrowStream` and `dotarrowStream2`.\n\nThe first is used to insert `_ \u003c- IO.canceled` cancellation points, while the second\nis used to transform the `Scalameta` `AST` by dropping the first `Enumerator.Generator`\ntogether with \"its\" `IO.canceled.`\n\nThe `examples/dotarrow` folder *must* have two sub-folders:\n\n    ./examples/dotarrow/\n       src/\n       tmp/\n\nThe `Scala` source files go in the `./examples/dotarrow/` folder.\n\nThe (parent) root folder contains three files for \"`stream`\" serialization:\n\n    ../dotarrow/stream/\n       app.scala.in\n       app2.scala.in\n       bin.in\n\nThe first two are used in the two shell functions, `dotarrowStream`, respectively,\n`dotarrowStream2`, while the third is copied initially as the object serialization\n(temporary) binary file.\n\nAnd two files for \"`circe`\" `JSON` serialization:\n\n    ../dotarrow/circe/\n       app.scala.in\n       app2.scala.in\n\nThese two are used in the two shell functions, `dotarrowCirce`, respectively,\n`dotarrowCirce2`.\n\n!!!Warning: do not delete them!!!\n\nThe `examples` folder contains a `dotarrow_stream_ex0.pisc` file. It contains embedded\n`Scala` code that uses the `scala.sys.process._` facility to execute `Scala` code\nas it is reduced to `_ \u003c- IO { ... }.void`; the final value `196.0` can be seen.\n\nTo \"execute\" the \"mobile code\", parse the `.pisc` file:\n\n    sbt:π-Calculus2Scala\u003e run dotarrow_stream_ex0\n\nChoose one example from the `examples/dotarrow/` folder, e.g., `ex3.scala`;\nthen - in a shell -, `cd` to `examples` folder, and run:\n\n    ./examples $ pio dotarrow_stream_ex0\n    ./examples $ pi dotarrow_stream_ex0.scala -- ex3\n\nNote how \"`ex3`\" was passed as an argument to the `main` method in `dotarrow_stream_ex0.scala`.\n\nTry the same, but using `circe`:\n\n    sbt:π-Calculus2Scala\u003e run dotarrow_circe_ex0\n    ./examples $ pio dotarrow_circe_ex0\n    ./examples $ pi dotarrow_circe_ex0.scala -- ex4\n\nOr both:\n\n    sbt:π-Calculus2Scala\u003e run dotarrow_stream_circe_ex_3_4\n    ./examples $ pio dotarrow_stream_circe_ex_3_4\n    ./examples $ pi dotarrow_stream_circe_ex_3_4.scala\n\nThe `Scala` source files must have a strict format:\n\n- the main object must be `object App extends IOApp.Simple`;\n\n- the main method must be `override def run: IO[Unit]`;\n\n- the body of the main method must be a `for-yield` comprehension;\n\n- variable-bound generators of the `for-yield` must bind a single variable *and*\n  be ascribed the type;\n\n- definitions of the `for-yield` must correspond to `case class`es, bind a\n  single variable for each parameter of the `case class`, and the right hand side\n  be a single variable that is bound - immediately preceding the definition - by\n  a generator _without_ an ascribed type (i.e., the `case class`);\n\n- names of variable-bound generators must not contain whitespace; their types may;\n\n- the scope of pattern variables in definitions and generators is limited until\n  the first variable-bound with ascribed type generator;\n\n- \"`if`\" guards are impossible as \"`withFilter`\" lacks from the `IO` monad;\n\n- the last `for-yield` statement must be `_ \u003c- IO { ... }.void`;\n\n- must not output to `scala.Console.err`;\n\n- characters in the `Scala` source files are not supported;\n\n- in addition, for `JSON` serialization with `circe`, the implicit\n  `Encoder`s/`Decoder`s must be in the scope of the main method.\n\n\nDotArrow - `Haskell`\n--------------------\n\nIt is possible for `Haskell` in [`PISC`](https://github.com/sjbiaga/pisc) because\nof three reasons - two as for `Scala` and third:\n\n- [`TemplateHaskell`](https://hackage.haskell.org/package/template-haskell) allows\n  for `BindS`s to be manipulated such that `exitFailure` is inserted after each\n  `do`-statement with a pattern variable with type signature.\n\nAlso, values can be encoded to/decoded from `JSON` using the `Haskell` library\n[aeson](https://hackage.haskell.org/package/aeson).\n\nThe `bin/pi.sh` shell script has been added two functions:\n\n- `dotarrowAeson` and `dotarrowAeson2`.\n\nTo \"execute\" the \"mobile code\", parse the `.pisc` file:\n\n    sbt:π-Calculus2Scala\u003e run dotarrow_aeson_ex0\n\nChoose one example from the `examples/dotarrow/` folder, e.g., `ex1/app/Main.hs`;\nthen - in a shell -, `cd` to `examples` folder, and run:\n\n    ./examples $ pio dotarrow_aeson_ex0\n    ./examples $ pi dotarrow_aeson_ex0.scala -- ex1\n\nNote how \"`ex1`\" was passed as an argument to the `main` method in `dotarrow_aeson_ex0.scala`,\nwhile the implied (see below) \"`app/Main.hs`\" was omitted.\n\n[`Haskell Tool Stack`](https://hackage.haskell.org/package/stack) must be used and the\nfolders (e.g., \"`ex1`\") must have a `.cabal` build file; the command line launched\nby `PISC` is, e.g.,\n\n    stack run -- /path/to/pisc/examples/dotarrow/tmp.../app/Main.hs\n\nfrom either two `dotarrow` - with \"`stack-cabal`\" setup - sub-folders:\n\n    ./dotarrow/aeson\n    ./dotarrow/aeson2\n\ncopied to, respectively:\n\n    /path/to/pisc/examples/dotarrow/tmp.../tmp/aeson\n    /path/to/pisc/examples/dotarrow/tmp.../tmp/aeson2\n\nfolders.\n\nThe `Haskell` source files must have a strict format:\n\n- the executable source file must be `app/Main.hs` with module `Main`;\n\n- among `import`s must be the following:\n\n        import System.Exit (exitFailure)\n        import System.IO (hPutStrLn, stderr)\n        import Inp_gUgVwYdD8r\n        import Out_gUgVwYdD8r\n\n  where modules `Inp_gUgVwYdD8r` and `Out_gUgVwYdD8r` must not be modified;\n\n- the main method signature `main :: IO ()` and declaration must be the last\n  two declarations;\n\n- the body of `main` must be a `do` notation;\n\n- `do` statements that bind must pattern-match a single variable with type assertion;\n\n- `do` statements that `let` must correspond to a unique-constructor `data`type,\n  bind a single variable for each parameter of the `data`type, and the right hand side\n  be a single variable that is bound - immediately preceding the `let` statement - by\n  a binding _without_ an asserted type (i.e., the `data`type);\n\n- the last `do` statement must be `return ()`;\n\n- must not output to `stderr`.\n\nDotArrow - `Scala` \u0026 `Haskell`\n------------------------------\n\nThis type of \"mobile code\" _alternatively_ takes the form of either\n`Scala` or `Haskell` programming language, but is very restricted.\n\nThe `bin/pi.sh` shell script has been added two functions:\n\n- `dotarrowScalaToHaskell` and `dotarrowHaskellToScala`.\n\nTo \"execute\" the \"mobile code\", parse the `.pisc` file:\n\n    sbt:π-Calculus2Scala\u003e run dotarrow_circe_aeson_ex0\n\nChoose one `Scala` example from the `examples/dotarrow/` folder, e.g., `ex5.scala`\nor `ex6.scala`, then - in a shell -, `cd` to `examples` folder, and run:\n\n    ./examples $ pio dotarrow_circe_aeson_ex0\n    ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex5\n\nNote how \"`ex5`\" was passed as an argument to the `main` method\nin `dotarrow_circe_aeson_ex0.scala`.\n\nThe `Scala` source files must have even a stricter format:\n\n- no `package` statements;\n\n- only simple arithmetic expressions (without division) of type `Int` in the\n  `IO { }` blocks;\n\n- `case class`es must not share parameter names - as these are translated\n  into `Haskell` unique-constructor `data`types with identical field labels.\n\nNote that both [`Scala Cli`](https://scala-cli.virtuslab.org/)\nand [`Ammonite`](https://ammonite.io/) must be installed, as well as\n[`Stack`](https://hackage.haskell.org/package/stack). Also, the\n`Perl`script [`bin/Scalameta2Haskell.pl`](https://github.com/sjbiaga/pisc-dotarrow/blob/main/bin/Scalameta2Haskell.pl)\nmust be available in the `PATH`.\n\nCodecs\n------\n\n`Codec`s is the codename for encoding \"programs\" as numeric expressions:\n\n- in `Scala` via providing an `implicit` `object` extending the `Numeric` trait;\n\n- in `Haskell` via providing an `instance` of the `Num` class.\n\nThere are currently two implementation of codecs:\n\n- lists of integers that can be added, negated or subtracted; the multiplication\n  operator is used to concatenate lists, e.g.,\n\n        ./examples $ pi dotarrow_codec_list_aeson_ex0.scala -- ex3\n        ./examples $ pi dotarrow_codec_list_circe_ex0.scala -- ex11\n\n- an expression `DSL` that mirrors the native numeric expressions, e.g.,\n\n        ./examples $ pi dotarrow_codec_idem_aeson_ex0.scala -- ex4\n        ./examples $ pi dotarrow_codec_idem_circe_ex0.scala -- ex12\n\nIn the latter `DSL` case, for example, the integers - either variables\nof type `Int` that have been previously bound, or literals - are wrapped\nwithin `fromInt` in an \"invisible\" step before the main program is run,\nand the numeric operations are actually performed with `DSL` values.\n\nExamples\n--------\n\nBecause the number of examples is growing rapidly, this is the list of the\ncommands with which they were tested as arguments:\n\n- `Scala`\n\n        ./examples $ pi dotarrow_circe_ex0.scala -- ex1\n        ./examples $ pi dotarrow_circe_ex0.scala -- ex2\n        ./examples $ pi dotarrow_stream_ex0.scala -- ex3\n        ./examples $ pi dotarrow_circe_ex0.scala -- ex4\n        ./examples $ pi dotarrow_codec_list_circe_ex0.scala -- ex11\n        ./examples $ pi dotarrow_codec_idem_circe_ex0.scala -- ex12\n        ./examples $ pi dotarrow_codec_idem_circe_ex0.scala -- ex13\n\n- `Haskell`\n\n        ./examples $ pi dotarrow_aeson_ex0.scala -- ex1\n        ./examples $ pi dotarrow_aeson_ex0.scala -- ex2\n        ./examples $ pi dotarrow_codec_list_aeson_ex0.scala -- ex3\n        ./examples $ pi dotarrow_codec_idem_aeson_ex0.scala -- ex4\n        ./examples $ pi dotarrow_codec_idem_aeson_ex0.scala -- ex5\n\n- `Scala` \u0026 `Haskell`\n\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex5\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex6\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex7\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex8\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex9\n        ./examples $ pi dotarrow_circe_aeson_ex0.scala -- ex10\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjbiaga%2Fpisc-dotarrow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjbiaga%2Fpisc-dotarrow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjbiaga%2Fpisc-dotarrow/lists"}