object - F#: I cannot return unit in a do clause and still have side effects -


I am writing a simple III file parser and I want to "do" section with the start of the object, The unit can be returned but I am trying to pip in "ignore" or if I return directly to "()" then the blank function can not be given to side effects.

This code works as a separate function because I can ignore the results.

  # Light Module Utilities Open system open system IO Open Systems Text. Regular Expression Open System Collection. Normal Type Edit (? Filename: string) = filename = defaultArg filename @ "C: \ path \ myConfigs.ini" static default default settings = dict ["setting 1", "1"; "Setting 2", "2"; "Debug", "0"; "State", "clutter";] setting regex = new regesx (@ "\ s * (?> <;;> ([^; # =] * [^; # =])) \ S * = \ S * (? & Gt; value & gt; ([^; #] * [^; #]) "File settings = new dictionary; string; string; () Let's addFileSetting (groups: grouping) = File settings go. (Group.item ("key"). Value, group.itim ("value") value) File Reidline (filename) |> Seq.map (funny row -> settings rezox Match (line)) |> Seq.filter (Funny Mtc -> mtch.Success) |> Seq.map (funny mtch -> Adfile Do not type correct return in Ting (MTP group) // // ignore ## 1 do not insert into dictionary // () // # 2 not init dictionary // additional step member c.ReadFile = The file will work.ReadLine (filename) | & gt; Seq.map (funny row -> rezox setting; match (line)) |> Seq.filter (funny MTP -> Mtch.Success) | & Gt; Seq.map (Fun MTC -> Adfile Settings (MTC Group))  

Seq Use "text">

Seq.iter instead of .map (To perform a function for each element - back unit ) element).

The code does not work with Ignore because Seq is evaluated indelibly and when you ignore the result, there is no need Is to run any code.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -