Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Higher-kinded endofunctors

Name: Anonymous 2015-04-02 22:10

Higher-kinded type classes is what makes Haskell stand out above other functional languages for me. Things like endofunctors just cannot exist in virtually any other language.

Name: Anonymous 2015-04-03 10:50

>>7
Lol idiot, of course you can rewrite it without compositions, anyone can. The problem is it will look and feel like shit.

But here's an example anyway (in Scala):

def bbCodeB(in: String): String = rBold.replaceAllIn(in, (m: Match) => "<b>" + (m group "c") + "</b>")
def bbCodeUrl(in: String): String = rLink.replaceAllIn(in, (m: Match) => "<a href=\"" + (m group "add") + "\">" + (m group "c") + "</a>")
def bbCodeC(in: String): String = rCode.replaceAllIn(in, (m: Match) => "<pre>" + (m group "c") + "</pre>")
def bbCodeS(in: String): String = rStrike.replaceAllIn(in, (m: Match) => "<span class=\"s\">" + (m group "c") + "</span>")
def bbCodeSp(color: String, in: String): String = rSpoiler.replaceAllIn(in, (m: Match) => """<span class="sp"
onmouseover="this.style.color=#000000;" onmouseout="this.style.color=""" + color + """;">""" + (m group "c") + "</span>")
def bbCodeU(in: String): String = rUnderline.replaceAllIn(in, (m: Match) => "<span class=\"un\">" + (m group "c") + "</span>")
def bbCodeI(in: String): String = rItalic.replaceAllIn(in, (m: Match) => "<i>" + (m group "c") + "</i>")
def bbCodeNl(in: String): String = rNewline.replaceAllIn(in, "<br />")

def apply_bbCodes(color: String, inp: String): String = (
bbCodeUrl _ compose
bbCodeB _ compose
bbCodeI _ compose
bbCodeC _ compose
(bbCodeSp(color, _: String)) compose
bbCodeU _ compose
bbCodeS _ compose
bbCodeNl
)(rGT.replaceAllIn(rLT.replaceAllIn(inp, "&lt;"), "&gt;"))


I know it looks like shit already, but that's because

not in haskell/Lisp

Obviously, without function composition it will look like a horrendously huge shit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List