F# representer 的正規化

概述 F# representer 套用到解答上的各種正規化


F# representer 會套用以下正規化:

移除註解

所有註解都會被移除。

之前

module Fake

(* Block comment
   on multiple lines *)

let message = "Hi" (* Block comment after code *)

// Double-slash comment on single line
let reply = "Yo" // Double-slash comment after code

/// <summary>This function adds two numbers</summary>
/// <param name="x">The first number</param>
/// <param name="y">The second number</param>
/// <returns>The first number added to the second number</param>
let add x y = x + y

之後

module Fake

let message = "Hi"

let reply = "Yo"

let add x y = x + y

移除匯入宣告

所有匯入宣告都會被移除。

之前

module Fake

open System
open System.IO

let message = "Hi"

之後

module Fake

let message = "Hi"

格式化程式碼

程式碼會使用 fantomas 程式庫 來格式化。 它會依照 F# 風格指南來格式化程式碼。 fantomas 套用的完整轉換清單請見這裡。

之前

module Fake

let  add ( birthDate  :  DateTime)  =
    birthDate.Add (    2.0)

type Volume =
| Liter of float
| USPint of float
| ImperialPint of float

之後

module Fake

let add (birthDate: DateTime) =
    birthDate.Add(2.0)

type Volume =
    | Liter of float
    | USPint of float
    | ImperialPint of float

正規化識別字

識別字會被正規化成佔位符值。

之前

module Fake

let foo x = x + 1

之後

module PLACEHOLDER_1

let PLACEHOLDER_3 PLACEHOLDER_2 = PLACEHOLDER_2 + 1