Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarao/lambda-scala
Type level lambda calculus in Scala
https://github.com/tarao/lambda-scala
lambda-calculus scala typelevel
Last synced: 22 days ago
JSON representation
Type level lambda calculus in Scala
- Host: GitHub
- URL: https://github.com/tarao/lambda-scala
- Owner: tarao
- Created: 2015-05-05T04:53:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-05T04:54:21.000Z (over 9 years ago)
- Last Synced: 2023-03-12T22:43:13.513Z (over 1 year ago)
- Topics: lambda-calculus, scala, typelevel
- Language: Scala
- Size: 97.7 KB
- Stars: 33
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Type level lambda calculus in Scala
===================================This repository demonstrates an implementation of lambda calculus in
Scala types.Untyped lambda calculus
-----------------------```scala
import lambda._
case class Equals[A >: B <: B, B]() // this checks type equalitytype S = x ->: y ->: z ->: ( x @@ z @@ (y @@ z) )
type K = x ->: y ->: xtype result = ( S @@ K @@ K @@ a ) # ->*
Equals[result, a]
```More examples are found in [TermSpec.scala][example].
### Syntax
| |Code |
|:------------------------|:-----------------|
|Variables |`a`, `b`, ..., `z`|
|Abstraction |`v ->: M` |
|Application |`M @@ N` |
|Terms |`M`, `N` |
|1-step beta reduction |`M # ->` |
|Multi-step beta reduction|`M # ->*` |- You can define your own variables by calling `#next` of existing (last defined) variable
```scala
type variableName1 = z #next
type variableName2 = variableName1 #next
```- You may need parenthesis to avoid ambiguity
### Capture-avoiding substitutions
Lambda terms are converted internally to
[De Bruijn indexed terms][debruijn] and indices are shifted during
substitution to ensure capture-avoiding semantics.License
-------- Copyright (C) INA Lintaro
- MIT LicenseReferences
----------- [Scala type level encoding of the SKI calculus][ski]
- [Type-Level Programming in Scala][typelevel][example]: src/test/scala/lambda/TermSpec.scala
[debruijn]: http://en.wikipedia.org/wiki/De_Bruijn_index
[ski]: https://michid.wordpress.com/2010/01/29/scala-type-level-encoding-of-the-ski-calculus/
[typelevel]: https://apocalisp.wordpress.com/2010/06/08/type-level-programming-in-scala/