Skip to content

Instantly share code, notes, and snippets.

View SRechenberger's full-sized avatar
💭
:godmode:

Sascha Rechenberger SRechenberger

💭
:godmode:
View GitHub Profile
@SRechenberger
SRechenberger / FreeCHR.hs
Last active March 27, 2024 10:57
FreeCHR instances
import Data.List hiding (nub)
import Prelude hiding (gcd)
-- FreeCHR Instance
newtype SolverStep c = SolverStep { runSolverStep :: [c] -> [c] }
match :: [a -> Bool] -> [a] -> [[a]]
match ps as = [ as''
| as' <- subsequences as, length as' == length ps
@SRechenberger
SRechenberger / FreeCHR.py
Last active January 1, 2024 05:12
Example Instances of FreeCHR
from itertools import permutations
def match(pattern, constraints):
return (perm
for perm in permutations(constraints, len(pattern))
if all(p(c) for p, c in zip(pattern, perm))
)