src/HOL/Library/Open_State_Syntax.thy
changeset 69593 3dda49e08b9d
parent 68224 1f7308050349
child 72581 de581f98a3a1
equal deleted inserted replaced
69592:a80d8ec6c998 69593:3dda49e08b9d
    57 
    57 
    58 notation fcomp (infixl "\<circ>>" 60)
    58 notation fcomp (infixl "\<circ>>" 60)
    59 notation scomp (infixl "\<circ>\<rightarrow>" 60)
    59 notation scomp (infixl "\<circ>\<rightarrow>" 60)
    60 
    60 
    61 text \<open>
    61 text \<open>
    62   Given two transformations @{term f} and @{term g}, they may be
    62   Given two transformations \<^term>\<open>f\<close> and \<^term>\<open>g\<close>, they may be
    63   directly composed using the @{term "(\<circ>>)"} combinator, forming a
    63   directly composed using the \<^term>\<open>(\<circ>>)\<close> combinator, forming a
    64   forward composition: @{prop "(f \<circ>> g) s = f (g s)"}.
    64   forward composition: \<^prop>\<open>(f \<circ>> g) s = f (g s)\<close>.
    65 
    65 
    66   After any yielding transformation, we bind the side result
    66   After any yielding transformation, we bind the side result
    67   immediately using a lambda abstraction.  This is the purpose of the
    67   immediately using a lambda abstraction.  This is the purpose of the
    68   @{term "(\<circ>\<rightarrow>)"} combinator: @{prop "(f \<circ>\<rightarrow> (\<lambda>x. g)) s = (let (x, s')
    68   \<^term>\<open>(\<circ>\<rightarrow>)\<close> combinator: \<^prop>\<open>(f \<circ>\<rightarrow> (\<lambda>x. g)) s = (let (x, s')
    69   = f s in g s')"}.
    69   = f s in g s')\<close>.
    70 
    70 
    71   For queries, the existing @{term "Let"} is appropriate.
    71   For queries, the existing \<^term>\<open>Let\<close> is appropriate.
    72 
    72 
    73   Naturally, a computation may yield a side result by pairing it to
    73   Naturally, a computation may yield a side result by pairing it to
    74   the state from the left; we introduce the suggestive abbreviation
    74   the state from the left; we introduce the suggestive abbreviation
    75   @{term return} for this purpose.
    75   \<^term>\<open>return\<close> for this purpose.
    76 
    76 
    77   The most crucial distinction to Haskell is that we do not need to
    77   The most crucial distinction to Haskell is that we do not need to
    78   introduce distinguished type constructors for different kinds of
    78   introduce distinguished type constructors for different kinds of
    79   state.  This has two consequences:
    79   state.  This has two consequences:
    80 
    80