{"id":16722300,"url":"https://github.com/phipsgabler/dsl-examples","last_synced_at":"2025-03-15T13:21:36.694Z","repository":{"id":31579886,"uuid":"35144658","full_name":"phipsgabler/dsl-examples","owner":"phipsgabler","description":"Shows examples of patterns used in Scala embedded DSLs.","archived":false,"fork":false,"pushed_at":"2019-10-12T20:01:40.000Z","size":27,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T03:33:05.550Z","etag":null,"topics":["dsl","functional-programming","scala"],"latest_commit_sha":null,"homepage":null,"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/phipsgabler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-06T07:12:23.000Z","updated_at":"2023-03-02T07:25:33.000Z","dependencies_parsed_at":"2022-08-24T06:50:34.652Z","dependency_job_id":null,"html_url":"https://github.com/phipsgabler/dsl-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phipsgabler%2Fdsl-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phipsgabler%2Fdsl-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phipsgabler%2Fdsl-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phipsgabler%2Fdsl-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phipsgabler","download_url":"https://codeload.github.com/phipsgabler/dsl-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243733336,"owners_count":20339026,"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":["dsl","functional-programming","scala"],"created_at":"2024-10-12T22:34:12.423Z","updated_at":"2025-03-15T13:21:36.672Z","avatar_url":"https://github.com/phipsgabler.png","language":"Scala","readme":"[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n# DSL-Examples #\n\nHere I implement various showcases of Scala features, mostly related to DSLs, to\nillustrate my bachelor's thesis.\n\nEvery example consists of a module object, containing all necessary definitions,\nand a \"test object\" (inheriting from `App`), in which calls or constructions are\nshown to typecheck or to work.\n\nThe \"tests\" should not be taken too seriously; they are only there to show how\nthe defined features can be used, not to ensure any invariants. Sometimes there aren't\neven any.\n\n## Usage ##\n\nThis is an SBT project; simply type `sbt console` on the top level. The package\n`dsl_examples` is automatically imported. To play around with individual features,\nyou can import their module objects, like `import Logic._`.\n\n\n# Description of Individual Examples #\n\n## [ChurchList](src/main/scala/dsl_examples/ChurchList.scala) ##\n\nAn implementation of [church encoded](https://en.wikipedia.org/wiki/Church_encoding) lists, illustrating the hiding\nof an internal implementation through an interface by `apply`/`unapply` in the companion object.\n\nThe interface is intended to look like the one of `List`: there are members `Empty` and `Cons`, as well as the\nuniversal constructor `ChurchList`, which all can be pattern matched on.\n\n## [Imperative](src/main/scala/dsl_examples/Imperative.scala) ##\n\nMethods `repeat` and `_while`, to illustrate how blocks and by-name arguments can be used to construct functions\nwhich look and behave like imperative language statements.\n\n## [Logic](src/main/scala/dsl_examples/Logic.scala) ##\n\nA small AST for predicate logic expressions, including an implementation function. Illustrates the use of operators and\nextractors.\n\n## [MutableDict](src/main/scala/dsl_examples/MutableDict.scala) ##\n\nA mutable dictionary implementation based on a purely functional internal implementation, illustrating the getter/setter\nsyntax of Scala.\n\n## [Range](src/main/scala/dsl_examples/Range.scala) ##\n\nA wrapper for `Int`, reimplementing the syntax from\n[`scala.collection.immutable.Range`](http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Range).\n\n## [Read](src/main/scala/dsl_examples/Read.scala) ##\n\nA simple example of a type class (inspired by Haskell's\n[`Read`](http://hackage.haskell.org/package/base-4.8.0.0/docs/Prelude.html#t:Read)), providing the functionality of\nreading a value of a type from a string.\n\n## [Recover](src/main/scala/dsl_examples/Recover.scala) ##\n\nA reimplementation of [`scala.util.Try`](http://www.scala-lang.org/api/current/index.html#scala.util.Try), illustrating\na usage of by-name parameters.\n\n## [SExpParser](src/main/scala/dsl_examples/SExpParser.scala) ##\n\nA small parser for [S-expressions](https://en.wikipedia.org/wiki/S-expression) (LISP syntax), using Scala's\nparser combinators.\n\n## [Delay](src/main/scala/dsl_examples/delay) ##\n\nMultiple versions of delay objects (similar to [futures](https://en.wikipedia.org/wiki/Futures_and_promises), but not\nactually using multi-threading).\n\n- `Delay1` uses a mutable variable and hides its internal state.\n- `Delay2` does in principle the same, but uses the Scala constructs for by-name arguments and lazy values.\n- `Delay3` factors out the interface into a trait, and provides a monadic interface.\n- `Delay4` is very similar to `Delay3`, but implements the monad type class from\n  [`Scalaz`](https://github.com/scalaz/scalaz).\n\n# License #\n\nThis stuff is available under the MIT license. See LICENSE.txt for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphipsgabler%2Fdsl-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphipsgabler%2Fdsl-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphipsgabler%2Fdsl-examples/lists"}