Skip to content

Instantly share code, notes, and snippets.

@lovelymono
lovelymono / dialog.html
Created April 12, 2022 10:47
Native dialog in HTML
<!-- You can use JSBin: https://jsbin.com/xoketogeda/edit?html,output to play around with it. -->
<!-- The dialog element is specified in HTML specification, §4.11.4 "The dialog
element": https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element. -->
<button onclick="document.querySelector('dialog').showModal()">Open dialog</button>
<dialog style="width: 50%;">
<h1>Native <code>&lt;dialog&gt;</code></h1>
@lovelymono
lovelymono / Parser.hs
Created May 3, 2022 12:03
Baseline for parser combinators in Haskell
import qualified Data.Text as T
data Error = EndOfInput | Unexpected Char
deriving (Eq, Show)
-- Parser from T.Text to some type a.
data Parser a = Parser { runParser :: T.Text -> Either Error (a, T.Text) }
satisfy :: (Char -> Bool) -> Parser Char
satisfy p = Parser $ \input ->