Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3394204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:08:32+00:00 2026-05-18T04:08:32+00:00

trying to follow example in the expert f# book, and having an issue with

  • 0

trying to follow example in the expert f# book, and having an issue with the workflows…the code is as follows:

type Attempt<'a> = option<'a>
let succeed x    = Some (x)
let fail         = None 

let bind p rest  = 
    match p with 
    | None -> fail 
    | Some r -> rest r

let delay f = f()

type AttemptBuilder() = 

    member b.Return (x) = succeed x
    member b.Bind (p, rest) = bind p rest
    member b.Delay (f) = delay f
    member b.Let (p, rest):Attempt<'a> = rest p  //'
    member b.ReturnFrom x = x


// using it: 
let attempt = new AttemptBuilder()

let test foo = 
    attempt {
        if not foo then return! fail else return foo
    }

let check () = 
    attempt {

        let! n1 = test true
        let! n2 = test false
        let! n3 = test true
        let foo = n1,n2,n3
        return foo
    }
let foo = check ()

problem is , when all values are true, i get as expected, a Some(true, true, true), but if one of the values passed in is false, foo is null (!). Anyone ftw?

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:08:33+00:00Added an answer on May 18, 2026 at 4:08 am

    This is just because None is actually represented as null at runtime (see the remarks on the Option<'T> page on MSDN). Also, note that you can add

    member x.Zero() = fail
    

    to your builder, and then you can write test as

    let test x = attempt { if x then return foo }
    

    which is a little cleaner to my eyes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow some example code from microsofts mdn site.. var WshShell =
I'm trying to follow the example at Logarithmic slider . Here's the code I'm
I have been trying to follow this example (download the source code from a
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
I am trying to follow this example (from p137 of Rob Pickering's Foundations of
I'm trying to follow the example on http://developers.cloudmade.com/wiki/iphone-sdk/Create_basic_Local_Search_and_Geocoding_app . The example from svn provided
I'm a newbie to sql and am trying to follow this example here: http://net.tutsplus.com/tutorials/php/a-better-login-system/
I am new to maven and I am trying to follow this example but
I'm trying to follow the Auth example for Webapp2 that can be found here:
The line below is completely failing. template: _.template($('#test').html()), Trying to follow a simple example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.