News for hackers. Stuff that matters.
Re:Reflections on Using Haskell for My Startup by ghostwriter on Friday February 19, 2021 @05:20PM (#26198767)
The first 2-minute experience with a Haskell web service:

  curl -L https://nixos.org/nix/install | sh
  
  cat > ./script.sh <<EOF
  #! /usr/bin/env nix-shell
  #! nix-shell <nixpkgs> -i runghc -p "ghc.withPackages (x: [ x.yesod ])"
  {-# LANGUAGE ExtendedDefaultRules #-}
  {-# LANGUAGE OverloadedStrings    #-}
  {-# LANGUAGE QuasiQuotes          #-}
  {-# LANGUAGE TemplateHaskell      #-}
  {-# LANGUAGE TypeFamilies         #-}
  import Yesod
  
  data App = App
  
  mkYesod "App" [parseRoutes|
    / HomeR GET
  |]
  
  instance Yesod App
  
  getHomeR = return $ object ["msg" .= "Hello!"]
  port     = 3000
  
  main = warp port App
  EOF
  
  chmod +x ./script.sh
  
  ./script.sh

There are no comments on this comment yet.