View CodeMesh2016.org

CodeMesh 2016 <2016-11-03 Thu>

Space Monads

We move the effort into designing the type, so that writing the algorithm is simpler.

[#B] Look at Hoare Logic

There is a relationship between monads and Hoare Logic. Can I solve the 9-jigsaw puzzle with Monads? https://en.wikipedia.org/wiki/Hoare_logic

Look at applications of Kleisli monads.

View elm-make-bug.sh
#!/bin/sh
############################################################
# Create a simple working program.
############################################################
cat <<EOF > Foo.elm
module Foo exposing (..)
type alias Foo = Int
EOF
View Demo.elm
module Main exposing (..)
import Html exposing (..)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick, on, targetChecked)
type View
= Ascending
| Descending
View Demo.elm
module Main exposing (..)
import Html exposing (..)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick, on, targetChecked)
type View
= Ascending
| Descending
View foo
module Main (..) where
intersectingMagnitude : Line -> Position -> Angle -> List Length
intersectingMagnitude ( ( sx, sy ), ( sa, sm ) ) ( rx, ry ) ra =
let
sdx =
cos (degrees sa)
rdx =
View person.hs
-- Both of these functions do the same thing: return some that, if given a DB connection, will return a list of records.
-- No type-checking, but obvious equivalence to SQL.
getPerson :: UUID -> SqlPersistM [Entity Person]
getPerson uuid = rawSql
rawSql "SELECT ?? FROM person WHERE person_id = ?" [uuid]
-- More DSL-ish, but more compile-time guarantees.
getPerson2 :: UUID -> SqlPersistM [Entity Person]
getPerson2 uuid =
View form.clj
(defn stateful-view []
(let [!form (reagent/atom {:name nil})]
(fn [ui-channel view-arg-1 view-arg-2]
[:form
[:input {:defaultValue (-> !form deref :name)
:onChange #(swap! !form assoc :name (.. % target value))}]])))
(defn regular-view
[ui-channel app]
[:div
View gist:5165b16e059f01bc44d1
var youtubeRegexp = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['][^<>]*>|<\/a>))[?=&+%\w.-]*/gi;
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU"));
// Prints true, false, true, false...
View haskell-completion.el
(require 'cl-lib)
(require 'thingatpt)
(defun haskell-process-completions-at-point ()
"A company-mode-compatible complete-at-point function."
(-when-let (process (haskell-process))
(-when-let (symbol (symbol-at-point))
(destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol)
(let ((completions (haskell-process-get-repl-completions (haskell-process)
(symbol-name symbol))))
View core.clj
(ns schemaspeed.core
(require [schema.core :as s]))
(def S {:name s/Str
:age s/Int
:things [s/Int]})
(def xs
(doall (repeat 100000
{:name "somename"