May 7, 2024, 10:30 a.m. | Dario Mannu

DEV Community dev.to

Can an HTML template be thought of a Monad, somehow? Maybe the IO Monad in particular?



const CoordsDisplay = (initial: Coords = [0, 0]) => {

const coords$ = new BehaviorSubject(initial).pipe(
map(([x, y]) => `( ${x} : ${y} )`)
);

return rml`
<div onmousemove="${eventXY(coords$)}"></div>
<span>${coords$}</span>
`;
};


Full source here


Comparing a Rimmel template (a rml tagged template literal) to the IO Monad can help in understanding the side-effects management and data-driven nature of UI rendering in functional programming, but …

functionalreactiveprogramming html javascript map rimmel template templates thought webdev

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US