Skip to content

feat: Datatype of thinnings#113

Merged
croyzor merged 3 commits intomainfrom
cr/thinnings_without_constraints
May 1, 2026
Merged

feat: Datatype of thinnings#113
croyzor merged 3 commits intomainfrom
cr/thinnings_without_constraints

Conversation

@croyzor
Copy link
Copy Markdown
Collaborator

@croyzor croyzor commented Apr 27, 2026

Add a datatype of thinnings, with static execution in the interpreter.

This only gets us a subset of the functionality that we ultimately want, because we want to add a constraint framework that can tell when a nat is equal to the length of omits in a thinning

@croyzor croyzor requested a review from acl-cqc April 27, 2026 12:46
Copy link
Copy Markdown
Collaborator

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't not approve given this has examples of thinnings that execute as well as typecheck ;-) but I'd like either removal of CRefl or a good justification of why it should stay in (what it does, use in an example) first please...

Comment thread brat/Brat/Constructors/Patterns.hs Outdated
Comment thread brat/Brat/Constructors.hs
(RPr ("value", VApp (VInx VZ) B0) R0))])
,(CTrue, M.fromList [(CBool, CArgs [] Zy R0 R0)])
,(CFalse, M.fromList [(CBool, CArgs [] Zy R0 R0)])
,(COmit, M.fromList
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I'm assuming we can't add the corresponding entry for CRefl here

pattern CConcatEqOdd = PrefixName [] "concatEqOdd"
pattern CRiffle = PrefixName [] "riffle"
pattern CRefl = PrefixName [] "refl"
pattern COmit = PrefixName [] "omit"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere round here (where COmit is declared) we should comment that the "opposite" of COmit is CSucc, i.e. nobody should go looking for CInclude

Comment thread brat/examples/thin.brat
-- This type is WRONG
test :: Vec(X, 2) <<< Vec(X, 2)
test = {0..} -- The identity thinning
identity(n :: #) -> Thin(n, n)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so we fix the parser failure by changing a <<< b into Thin(a,b)....I mean, that's the PR, right? 😁 😁

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a happy coincidence that these two functions lined up in the diff!

Comment thread brat/examples/thin.brat
go2 :: Vec(Nat, 3)
go2 = select(!, !, !, thinning1, [1,2,3,4,5])

--!exec [[3]]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! :)

@croyzor
Copy link
Copy Markdown
Collaborator Author

croyzor commented May 1, 2026

Agreed! I thought I had pulled out the CRefl parts...

@croyzor croyzor merged commit 193d33f into main May 1, 2026
1 check passed
@croyzor croyzor deleted the cr/thinnings_without_constraints branch May 1, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants