fizzbuzz - Algebra Driven Design

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

drew verlee

Danial's dicussion on fizzbuzz, which i don't have the prerequists to follow in detail, reminded me of this "art" piece by aphyr. https://aphyr.com/posts/342-typing-the-technical-interview

I forgot what a masterpiece this was. Where else could:

Her spells would never crash, and she became a friend to outcast women: the predecessors of your kind. It is said that Odin himself learned immortality from her.

The walls smell of Slack DMs and conflict avoidance.

Be separated by online a few sentences? He is truly the voice of the next generation.

drew verlee

class First list x | list -> x
instance First Nil Nil
instance First (Cons x more) x

The last line is confusing to me. Oh never mind he actually explains: and First on a Cons cell returns that cell’s value, x.” This is another area where haskell confused me, the syntax. There seems be too much of it. Or there isn't enough, i can't tell. Oh, i guess were referring to the Cons cell, not the act of getting the first thing. I'll allow it.

class ListConcat a b c | a b -> c
instance ListConcat Nil x x
instance (ListConcat as bs cs)
=> ListConcat (Cons a as) bs (Cons a cs)

it hurts a bit to look at, but recursion always does.

data True
data False

class Not b1 b | b1 -> b
instance Not False True
instance Not True False

class Or b1 b2 b | b1 b2 -> b
instance Or True True True
instance Or True False True
instance Or False True True
instance Or False False False

I also define boolean logic in my interviews. It's a good way to make sure company understands the basics before we get into really complex stuff like centering divs.