Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/HOL/Library/   (Isabelle Prover Version 2025-1©)  Datei vom 16.11.2025 mit Größe 2 kB image not shown  

Quelle  Monad_Syntax.thy

  Sprache: Isabelle
 

(*  Title:      HOL/Library/Monad_Syntax.thy
    Author:     Alexander Krauss, TU Muenchen
    Author:     Christian Sternagel, University of Innsbruck
*)


section Monad notation for arbitrary types

theory Monad_Syntax
  imports Main
begin

text 
  provide a convenient do-notation for monadic expressions well-known from Haskell.
 constLet is printed specially in do-expressions.
 


consts
  bind :: "'a ('b 'c) 'd" (infixl  54)

notation (ASCII)
  bind (infixl >>= 54)


abbreviation (do_notation)
  bind_do :: "'a ('b 'c) 'd"
  where "bind_do bind"

notation (output)
  bind_do (infixl  54)

notation (ASCII output)
  bind_do (infixl >>= 54)


nonterminal do_binds and do_bind
syntax
  "_do_block" :: "do_binds 'a"
    ((open_block notation=mixfix do blockdo {//(2 _)//}) [1262)
  "_do_bind"  :: "[pttrn, 'a] do_bind"
    ((indent=2 notation=infix do bind_ / _) 13)
  "_do_let" :: "[pttrn, 'a] do_bind"
    ((indent=2 notation=infix do letlet _ =/ _) [10001313)
  "_do_then" :: "'a do_bind"  (_ [1413)
  "_do_final" :: "'a do_binds"  (_)
  "_do_cons" :: "[do_bind, do_binds] do_binds"
    ((open_block notation=infix do next_;//_) [131212)
  "_thenM" :: "['a, 'b] 'c"  (infixl  54)

syntax (ASCII)
  "_do_bind" :: "[pttrn, 'a] do_bind"
    ((indent=2 notation=infix do bind_ <-/ _) 13)
  "_thenM" :: "['a, 'b] 'c"  (infixl >> 54)

syntax_consts
  "_do_block" "_do_cons" "_do_bind" "_do_then"  bind and
  "_do_let"  Let

translations
  "_do_block (_do_cons (_do_then t) (_do_final e))"
     "CONST bind_do t (λ_. e)"
  "_do_block (_do_cons (_do_bind p t) (_do_final e))"
     "CONST bind_do t (λp. e)"
  "_do_block (_do_cons (_do_let p t) bs)"
     "let p = t in _do_block bs"
  "_do_block (_do_cons b (_do_cons c cs))"
     "_do_block (_do_cons b (_do_final (_do_block (_do_cons c cs))))"
  "_do_cons (_do_let p t) (_do_final s)"
     "_do_final (let p = t in s)"
  "_do_block (_do_final e)"  "e"
  "(m n)"  "(m (λ_. n))"

adhoc_overloading
  bind  Set.bind Predicate.bind Option.bind List.bind

end

Messung V0.5 in Prozent
C=61 H=72 G=66

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-29) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.