Why does F # output my function, implement IComparable?

I am a hobby programmer (cook by profession), who is currently trying to teach myself F # and functional programming in general.

In any case, I cheated DeflateStreamand wrote the following two functions:

let Compress compressMe =
    let ds = new DeflateStream(File.Create("compressed.txt"), CompressionMode.Compress)
    File.OpenRead(compressMe).CopyTo(ds)
    ds.Close()

let Decompress =
    let ds = new DeflateStream(File.OpenRead("compressed.txt"), CompressionMode.Decompress)
    ds.CopyTo(File.Create("decompressed.txt"))
    ds.Close()

In the body of the main function, they are called one after another as follows:

Compress args.[0]
Decompress

, .txt Decompress a FileNotFoundException, , , , File.OpenRead("compress.txt"). , Decompress IComparable . , , let Decompress () = [...], IComparable, , . - , F # IComparable , [<EntryPoint>]? , , , .

adavance.

+3
3

IComparable, , Decompress , . , .

let compressedName = "compressed.txt"

compressedName . , , , -, ( ) , .

+4

-

let value = 
    //some long calculation
[<Entrypoint>]
let main args = ...

main. , , , . , , let value() = ....

, Icomparable, , .

,

let a = ...
let b = ...

, a b.

+4

, .

let Decompres = ...

declares a type variable unit. This type is used to represent "data" (even if that data does not encode a lot of information), and it implements IComparable, like any other data-oriented type.

let Decompress() = ...

declares a function, and the functions in F # are not comparable, probably because there is no generally accepted concept of equality in functions.

I do not see that "IComparable-ness" of Decompresshas anything to do with the exception you received.

0
source

All Articles