Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /tests/trunk/bugs/tests.obsolete/bug1322.1.sml
ViewVC logotype

Annotation of /tests/trunk/bugs/tests.obsolete/bug1322.1.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2460 - (view) (download)

1 : dbm 548 (* bug1322.1.sml *)
2 :    
3 :     signature MONAD =
4 :     sig
5 :     type 'a T
6 :     val unit : 'a -> 'a T
7 :     val bind : 'a T -> ('a -> 'b T) -> 'b T
8 :     end;
9 :    
10 :     structure IdMonad =
11 :     struct
12 :     type 'a T = 'a
13 :     fun unit x = x
14 :     fun bind m f = f m
15 :     end;
16 :    
17 :     functor StMonad(structure Monad : MONAD type State) =
18 :     struct
19 :     structure M =
20 :     struct
21 :     type 'a T = State -> (State * 'a) Monad.T
22 :     fun unit x = fn s => Monad.unit (s, x)
23 :     fun bind m k = fn s0 => Monad.bind (m s0) (fn (s1, a) => k a s1)
24 :     end
25 :     fun update f = fn s => Monad.unit (f s, s)
26 :     (* Works if you remove this defn *)
27 :     val read = update (fn s : State => s)
28 :     end;
29 :    
30 :     structure StMonad = StMonad(structure Monad = IdMonad type State = int);

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0