stan-dev / stan-dev/stanc3

[FR] Bool data type?

Open
#1,328 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

Would it be tricky/breaking to add support for a bool/boolean data type? All of the conditional/comparison operators require a boolean value, so users currently have to re-evaluate the condition at each call or rely on the implicit conversion from an int type.

It could make for cleaner syntax to be able to do something like:

data {
  real y_mean;
  bool use_log;
}
parameters {
  real y;
}
model {
  if (use_log) {
    y ~ lognormal(y_mean, 1);
  } else {
    y ~ normal(y_mean, 1);
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how conditional and comparison operators, implicit int conversion, and declarations are represented in the Stan transpiler. Define the required syntax and type-checking behavior, then verify that the example compiles and behaves correctly with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.