File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1+ Require Import Coq.Strings.String.
2+ Require Import ExtLib.Structures.MonadWriter.
3+ Require Import ExtLib.Data.Monads.WriterMonad.
4+ Require Import ExtLib.Data.Monads.IdentityMonad.
5+ Require Import ExtLib.Programming.Show .
6+
7+ Definition PrinterMonad : Type -> Type :=
8+ writerT (@show_mon _ ShowScheme_string_compose) ident.
9+
10+ Definition print {T : Type } {ST : Show T} (val : T) : PrinterMonad unit :=
11+ @MonadWriter.tell _ (@show_mon _ ShowScheme_string_compose) _ _
12+ (@show _ ST val _ show_inj (@show_mon _ ShowScheme_string_compose)).
13+
14+ Definition runPrinter {T : Type } (c : PrinterMonad T) : T * string :=
15+ let '(val,str) := unIdent (runWriterT c) in
16+ (val, str ""%string).
17+
18+
19+ Eval compute in runPrinter (Monad.bind (print 1) (fun _ => print 2)).
You can’t perform that action at this time.
0 commit comments