Rattus: A modal FRP language

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

This library implements the Rattus programming language as an embedded DSL. To this end the library provides a GHC plugin that performs the additional checks that are necessary for Rattus. What follows is a brief introduction to the language and its usage. A more detailed introduction can be found in this paper.

Rattus is a functional reactive programming (FRP) language that uses modal types to ensure operational properties that are crucial for reactive programs: productivity (in each computation step, the program makes progress), causality (output depends only on current and earlier input), and no implicit space leaks (programs do not implicitly retain memory over time).

To ensure these properties, Rattus uses the type modality O to express the concept of time at the type level. Intuitively speaking, a value of type O a represents a computation that will produce a value of type a in the next time step. Additionally, the language also features the Box type modality. A value of type Box a is a time-independent computation that can be executed at any time to produce a value of type a.

The core of the language is defined in the module Rattus.Primitives. Note that the operations on O and Box have non-standard typing rules. Therefore, this library provides a compiler plugin that checks these non-standard typing rules. To write Rattus programs, one must enable this plugin via the GHC option -fplugin=Rattus.Plugin, e.g. by including the following line in the source file (for better error messages we also suggest using the option -g2):

{-# OPTIONS -fplugin=Rattus.Plugin #-}

In addition, one must mark the functions that are written in Rattus:

{-# ANN myFunction Rattus #-}

Or mark the whole module as a Rattus module:

{-# ANN module Rattus #-}

Below is a minimal Rattus program using the Rattus.Stream module for programming with streams:

{-# OPTIONS -fplugin=Rattus.Plugin #-}

import Rattus
import Rattus.Stream

{-# ANN sums Rattus #-}
sums :: Str Int -> Str Int
sums = scan (box (+)) 0

Properties

Versions 0.1.0.0, 0.1.0.0, 0.1.1.0, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.5.0.1, 0.5.1, 0.5.1.1
Change log CHANGELOG.md
Dependencies base (>=4.12 && <5), containers, ghc (>=8.6), simple-affine-space [details]
License BSD-3-Clause
Copyright Copyright (C) 2020 Patrick Bahr
Author Patrick Bahr
Maintainer Patrick Bahr <paba@itu.dk>
Category FRP
Home page https://github.com/pa-ba/Rattus
Uploaded by PatrickBahr at 2020-07-13T21:02:30Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees