• entries
359
237
• views
188610

# Adventures in F# Part 1

51 views

I finished my first F# app in about 2 hours. No feedback at deadline and it's been pushed off the main page. Alas.

I am a little disappointed so far. Pattern matching, which seems to be one of the big things promoted as functional stuff to learn seems at face value to be not much more than nicer syntax for if/else/switch blocks. Not anything particularly new. I assume I'm just missing some nuance or situation where it is balls out fantastic.

The MSVS integration is okay. Syntax highlighting is sparse, its not really polished, and it wants to label stuff with weird errors a little prematurely. Intellisense is a little quirky, but works pretty well even with type inference everywhere. Most importantly, it works with little focus to the underlying bits and with consistency. Now if they could just make the intellisense case insensitive like it is with other languages and I'll be happy.

The language itself is okay I suppose. I dislike the lowercase function names, and example's functional drive to cram the most function into the least amount of space. x -> x*x is nice and direct, but more complex things quickly get out of hand. I was a perl nut for about a year, but executable line noise is not the way to go...

And re-pasted from the thread for posterity, F# part 1: Print Lines of Code in a MSVS solution (minus exception handling).

#lightopen System.IO;let IsSourceLine (Line:System.String) = Line.Trim().StartsWith(")let GetLineCount FileName =  File.ReadAllLines(FileName).Lengthlet GetSourceFileFromCompileLine Line=  let words = String.split ['\"'] Line  List.nth words 1let ProjectLines ProjectPath =  let BaseDirectory = Directory.GetParent(ProjectPath).ToString()  let ProjectFileLines = List.of_array (File.ReadAllLines(ProjectPath))  let CompileLines = ProjectFileLines.Filter IsSourceLine  let SourceFiles = CompileLines.Map GetSourceFileFromCompileLine  let SourcePaths = SourceFiles.Map (fun x -> BaseDirectory + "\\" + x)  SourcePaths.Iterate (fun x -> System.Console.WriteLine(x))  let SourceFileLineCount = SourcePaths.Map GetLineCount  List.fold_left (+) 0 SourceFileLineCount  let IsProjectLine (Line:System.String) = Line.StartsWith("Project")  let GetProjectPath Line =   let words = String.split [','] Line  let second = List.nth words 1  let second = second.Replace("\"","")  second.Trim()  let LinesPerSolutionFile SolutionFile =   let BaseDirectory = Directory.GetParent(SolutionFile).ToString()   let Lines = List.of_array (File.ReadAllLines(SolutionFile))   let Lines = Lines.Filter IsProjectLine   let ProjectFiles = Lines.Map GetProjectPath   let ProjectPaths = ProjectFiles.Map (fun x -> BaseDirectory + "\\" + x)   //ProjectPaths.Iterate (fun x -> System.Console.WriteLine(x))   let ProjectLineCounts = ProjectPaths.Map ProjectLines   List.fold_left (+) 0 ProjectLineCountslet Main =  //let args = Set.of_array (System.Environment.GetCommandLineArgs())  let args = [@"C:\src\Csharp-moeClient2\Csharp-moeClient2.sln"]  let LineCounts = args.Map LinesPerSolutionFile  System.Console.WriteLine()  (List.combine args LineCounts).Iterate (fun (path, lineCount) -> System.Console.WriteLine("{0}: {1}",path,lineCount)) //do System.Console.WriteLine("Foo.");   //do Main    do System.Threading.Thread.Sleep(5000)

There are no comments to display.

## Create an account

Register a new account