- fmap : (a -> b) -> m a -> m b
- f : a -> b
- mv : m a
- fmap f mv : m b
Applicative Functor
(ns smm.core | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic]) | |
(:require [clojure.core.logic.fd :as fd])) | |
;;; S E N D | |
;;; + M O R E | |
;;; --------- | |
;;; M O N E Y |
--- | |
- hosts: | |
- servers | |
vars: | |
ansible_ssh_user: root | |
tasks: | |
- name: make sure local keys directory exists | |
local_action: file path=./keys state=directory | |
- name: check key pair exists | |
local_action: command test -f keys/id_rsa |
# 末尾に追加 | |
latex_elements['preamble'] = r''' | |
\usepackage[export]{adjustbox} | |
\usepackage{letltxmacro} | |
\LetLtxMacro{\origincludegraphics}{\includegraphics} | |
\renewcommand*\includegraphics[2][max width=\textwidth,max height=\textheight,keepaspectratio]{% | |
\begin{figure}[htbp] | |
\origincludegraphics[#1]{#2} | |
\end{figure} |
(ns testmonad.core) | |
;;; Typeclass Protocols | |
(defprotocol Functor | |
(fmap [mv f] "f : a -> b, mv : m a, fmap f mv : m b")) | |
(defprotocol Applicative | |
(ap [mf mv] "mf : m (a -> b), mv : m a, ap mf mv : m b")) |
(ns testmonad.amonad-test | |
(:use [clojure.test] | |
[clojure.algo.monads])) | |
(defprotocol Either | |
(either-call [obj on-left on-right])) | |
(defrecord Left [v] | |
Either (either-call [obj on-left on-right] (on-left v))) | |
(defrecord Right [v] | |
Either (either-call [obj on-left on-right] (on-right v))) |
(defprotocol Monad | |
(return [m v]) | |
(bind [m mv f])) | |
(defprotocol MonadPlus | |
(mzero [m]) | |
(mplus [m mv mw])) | |
;; identity monad |
;;; Monad | |
(defprotocol [m] Monad | |
([a] return [ctx, v :- a] :- (m a)) | |
([a b] bind [ctx, mv :- (m a), f :- [a -> (m b)]] :- (m b))) | |
(defalias TFn1 (TFn [[x :variance :covariant]] Any)) | |
;;; Identity Monad |
package t | |
import scalaz._ | |
import Scalaz._ | |
import scala.collection.immutable._ | |
object rwse { | |
type ErrMsg = String | |
abstract sealed class Err | |
case class EmptyErr() extends Err |
abstract sig Board { | |
maxadjs: Int | |
} | |
abstract sig Side {} | |
one sig Inside, Outside extends Side {} | |
abstract sig Cell { | |
adjacent: some Cell, | |
num: Int, |