Intro

https://slides.com/emhoracek/haskell/live

Part 1

The Project

https://slides.com/emhoracek/haskell/live

Jacobin Magazine

  • Founded in 2011 with WordPress
  • Bhaskar Sunkara: founder and editor-in-chief
  • Remeike Forbes: creative director, designer, and front-end developer
  • Daniel Patterson built the subscription management system in Haskell

https://slides.com/emhoracek/haskell/live

Position Development

  • Daniel co-founded Position Development in 2014
  • When I joined in 2015, Haskell was small % of work
  • When Daniel left in 2016, he handed the Haskell projects off to me
  • Most were dormant, but Jacobin had one project coming up

https://slides.com/emhoracek/haskell/live

Jacobin "Redesign"

Before

WordPress with Haskell app embedded in iFrames

Problems

  • Using two template languages: WordPress/PHP and Haskell's Heist
  • Difficult to make iframe layouts mobile-friendly and responsive
  • Hard to share styling code across WP and Haskell
  • Unstructured articles made consistent styling hard

https://slides.com/emhoracek/haskell/live

Goals

  • WordPress is just for editors and writers (not readers)
  • Posts/articles are structured, with different types of posts structured in different ways
  • All pages use the same template and style language
  • Mobile-friendly and responsive

https://slides.com/emhoracek/haskell/live

Haskell app serves content from WordPress API

Jacobin "Redesign"

After

Part 2

How we did it

https://slides.com/emhoracek/haskell/live

WordPress

  • WP REST API
  • Advanced Custom Fields

Offset templates

<wpPostByPermalink>

  <apply template="_post">

    <wpMultisection>
      <wpSections>
        <wpSection>
          <section class="po-cn__section po-wp__section" id="ch-${wpSectionsIndex}">
            <if exists="${wpTitle}">
              <then><h1 class="po-cn__subhead po-wp__subhead"><wpTitle/></h1></then>
              <else><hr class="po-cn__rule po-wp__rule"/></else>
            </if>
            <wpContent/>
          </section>
        </wpSection>
      </wpSections>
    </wpMultisection>

  </apply>

</wpPostByPermalink>

https://slides.com/emhoracek/haskell/live

Custom Fields with Offset

multiSectionFields :: Field Ctxt
multiSectionFields = CN "multisection"
                       ["acf"]
                       [ M "sections"
                         [ F "title"
                         , M "section"
                           [ F "content" ] ] ]

https://slides.com/emhoracek/haskell/live

Custom Post Types

postByPermalinkHandler :: Ctxt -> Text -> Text -> Text -> IO (Maybe Response)
postByPermalinkHandler ctxt year month slug =
   do let key = PostByPermalinkKey year month slug
      mpost <- evalStateT (wpGetPost wordpress key) ctxt
      case mpost of
        Nothing -> return Nothing
        Just post ->
          do render ctxt ("post-types/" <> postFormat post)

https://slides.com/emhoracek/haskell/live

Speeding up development

  • Offset only queried to specific endpoints with specific structures
  • How can we enable Remeike and Pea to iterate on the WP structure and frontend without waiting for us to build specific endpoints?

https://slides.com/emhoracek/haskell/live

wpCustom

  • Bullet One
  • Bullet Two
  • Bullet Three

https://slides.com/emhoracek/haskell/live

The end result

https://slides.com/emhoracek/haskell/live

Part 3

Challenges

https://slides.com/emhoracek/haskell/live

https://slides.com/emhoracek/haskell/live

https://slides.com/emhoracek/haskell/live

The Genius-Oh-No Cycle

https://slides.com/emhoracek/haskell/live

The Genius-Oh-No Cycle

https://slides.com/emhoracek/haskell/live

The Genius-Oh-No Cycle

https://slides.com/emhoracek/haskell/live

The Genius-Oh-No Cycle

https://slides.com/emhoracek/haskell/live

no the problem isn't calling yourself a genius

Chesterton's Fence

https://slides.com/emhoracek/haskell/live

https://slides.com/emhoracek/haskell/live

According to my research the fence was built as an art project and abandoned in 1932!

THERE WAS A RAMPAGING BULL BEHIND THE FENCE

idk what if it's important?????

who knows????

I'll research the historical owners of the surrounding property.

What is the difference between

"this is bad"

and

"I don't understand this"?

The Haskell community

https://slides.com/emhoracek/haskell/live

Stereotype threat

https://slides.com/emhoracek/haskell/live

Part 4

Things that helped

https://slides.com/emhoracek/haskell/live

Pair programming

Test-driven development

Code review

Spikes and experiments

RFCs

For companies:

Can't find a person with extensive experience developing Haskell web applications? Try:

 

a person with knowledge of Haskell

plus

a person with experience in web applications

 

It works!

Finally

  • I work at Position Dev
    • We're accepting new clients for 2019!
    • positiondev.com / @positiondev
  • Twitter: @horrorcheck
  • Slides: https://slides.com/emhoracek/haskell/live
Made with Slides.com