~scompall/+junk/linq-resources--mainline

« back to all changes in this revision

Viewing changes to Nocandy.LinqResources.FS/ReaderVExample.fs

  • Committer: Stephen Compall
  • Date: 2012-10-22 03:17:56 UTC
  • Revision ID: scompall@nocandysw.com-20121022031756-5f98och3xi1dm1u0
main for F# ReaderVExample

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
type Program = {User : UserInfo; Settings : string -> string}
23
23
 
24
24
module Scaffold =
25
 
    let main = 42
26
 
 
27
25
    /// Succeed iff the program can be run.
28
26
    let mustBeRunnable() =
29
27
        rv.s { let! prg = rv.ask
60
58
               return! rv.s.Combine(describeLong().Filter(fun _ -> vb),
61
59
                                    describeShort())
62
60
                           .Contramap(fun p -> p.User) }
 
61
 
 
62
    let mapGet (m: Map<'k, 'v>) k = m.Item(k)
 
63
 
 
64
    let main (name, age, settings) =
 
65
        describe().ButFirst(mustBeRunnable2())
 
66
          .Run({User = {Name = name; Age = age};
 
67
                Settings = mapGet settings})
 
68
          .Fold(sprintf "ERROR: %s",
 
69
                sprintf "Exception: %A",
 
70
                id)