Is it possible to print full list without using cycle? I tried:
Console.WriteLine([1;2;3;4;5])
and it prints only three first elements:
In general, if you want to change as a way an printf "%A" prints your objects as a way fsi.exe shows values fo your type, you can apply StructuredFormatDisplayAttribute attribute to your type:
[]
type Foo(a:string array) =
let pp = Array.mapi (fun i (s: string) -> sprintf "{idx: %d len: %d contents: '%s'}" i s.Length s) a
member x.PrettyPrinter = pp
> let foo = Foo [|"one";"two";"three"|];;
val foo : Foo =
PP [|"{idx: 0 len: 3 contents: 'one'}"; "{idx: 1 len: 3 contents: 'two'}";
"{idx: 2 len: 5 contents: 'three'}"|]
> printfn "%A" foo;;
PP [|"{idx: 0 len: 3 contents: 'one'}"; "{idx: 1 len: 3 contents: 'two'}";
"{idx: 2 len: 5 contents: 'three'}"|]
val it : unit = ()