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

import 선언 제거

모든 import 선언이 제거돼요.

변경 전

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