src/HOL/Library/State_Monad.thy
changeset 21404 eb85850d3eb7
parent 21283 b15355b9a59d
child 21418 4bc2882f80af
equal deleted inserted replaced
21403:dd58f13a8eb4 21404:eb85850d3eb7
    66   we use a set of monad combinators:
    66   we use a set of monad combinators:
    67 *}
    67 *}
    68 
    68 
    69 definition
    69 definition
    70   mbind :: "('a \<Rightarrow> 'b \<times> 'c) \<Rightarrow> ('b \<Rightarrow> 'c \<Rightarrow> 'd) \<Rightarrow> 'a \<Rightarrow> 'd"
    70   mbind :: "('a \<Rightarrow> 'b \<times> 'c) \<Rightarrow> ('b \<Rightarrow> 'c \<Rightarrow> 'd) \<Rightarrow> 'a \<Rightarrow> 'd"
    71     (infixl ">>=" 60)
    71     (infixl ">>=" 60) where
    72   "f >>= g = split g \<circ> f"
    72   "f >>= g = split g \<circ> f"
       
    73 
       
    74 definition
    73   fcomp :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c"
    75   fcomp :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c"
    74     (infixl ">>" 60)
    76     (infixl ">>" 60) where
    75   "f >> g = g \<circ> f"
    77   "f >> g = g \<circ> f"
    76   run :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
    78 
       
    79 definition
       
    80   run :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" where
    77   "run f = f"
    81   "run f = f"
    78 
    82 
    79 print_ast_translation {*[
    83 print_ast_translation {*[
    80   (Sign.const_syntax_name (the_context ()) "State_Monad.run", fn (f::ts) => Syntax.mk_appl f ts)
    84   (Sign.const_syntax_name (the_context ()) "State_Monad.run", fn (f::ts) => Syntax.mk_appl f ts)
    81 ]*}
    85 ]*}