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 8500989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:05:21+00:00 2026-06-11T01:05:21+00:00

I am converting several modules based on OCaml to F#. I have the code

  • 0

I am converting several modules based on OCaml to F#. I have the code converted and running in F#, however the result of the final function in F# is not the same as the result of the final function in OCaml. So obviously I have to follow the function calls to figure out which function is returning the wrong result.

OCaml has a nice top-level directive for tracing the input and output of a function, i.e. #trace .

I have searched F#’s debug and trace methods and the closest I get is to instrument the code using Trace.Write methods but it takes several lines for each method.

e.g.

Original

let fun001 parm001 =
  parm001 * 10

Instrumented

let fun001 parm001 =
  // For VS 2010, this trace output will be sent to Output window.
  System.Diagnostics.Trace.WriteLine("function001 <--");      
  System.Diagnostics.Trace.WriteLine(sprintf "%A" parm001);      
  let result = parm001 * 10
  System.Diagnostics.Trace.WriteLine("function001 -->");
  System.Diagnostics.Trace.WriteLine(sprintf "%A" result);
  result

Does F# have the same functionality as OCaml #trace that I missed when searching?

If you are sure the answer is no, that’s all I need. I know people frown on short answers, but that is all I need if the answer is no.

EDIT

For more complex methods where capturing the result would evolve extensive modification to the code

Original

let func001 parm001 parm002 =
    match parm001 with
    | pattern001 -> func002 parm002
    | head :: tail -> 
        func003 head
        func001 tail
    | [] -> failwith "failed"

Instrumented

let func001org parm001 parm002 =
    match parm001 with
    | pattern001 -> func002 parm002
    | head :: tail -> 
        func003 head
        func001 tail
    | [] -> failwith "failed"
and fun001 parm001 parm002 =
  // For VS 2010, this trace output will be sent to Output window.
  System.Diagnostics.Trace.WriteLine("function001 <--");      
  System.Diagnostics.Trace.WriteLine(sprintf "%A, %A" parm001 parm002 );      
  let result = func001org parm001 parm002 
  System.Diagnostics.Trace.WriteLine("function001 -->");
  System.Diagnostics.Trace.WriteLine(sprintf "%A" result);
  result

EDIT

PostSharp does not support F#. See: Using PostSharp with F# – Need documentation with working example

  • 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-06-11T01:05:23+00:00Added an answer on June 11, 2026 at 1:05 am

    No (although I would love to have such a facility in F#).

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

Sidebar

Related Questions

I am converting several modules based on OCaml to F# and ran into something
I am converting several modules based on OCaml to F# and ran into the
I have evaluated several development tools for converting my informix SQL-based app. They are:
We are upgrading/converting several old Access databases to MS-SQL. Many of these databases have
I need a little help converting some VB.NET code to C#. I have tried
I have have several lines from a table that I’m converting from Excel to
I'm slowly converting my existing code into Delphi 2010 and read several of the
Sorry I have several question relative to the same problem. I am using Netbeans
I have been tasked with converting several php classes into java classes, which is
As an example, I have an several extension methods for converting strings and objects

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.