got a question - I am considering to redo some c# library parsing code - essentially it is parsing some nested structures with variable types. currently it is basically one big switch statement in c#- not sure how I should do pattern matching with different result types or just work with a boolean fake result?
I am getting data from a system via a socket protocol which is similar to BNF syntax - for a few things the data is an enum where discriminated union fits well, but most is basic types like int, float, date, time
just did my first xml type provider usage on sth more complex - remember a few years ago doing some xsd2code stuff and this is a much better experience
what I dislike about f# is the lack to add simple config parameters in f# - now I will need to add config xml on my own using the xml type provider ;-)
@7sharp9 Do you know of any example that makes something similar. Take some quotation expression, use metadata to transform/add code to that expression and then compile the code so runtime speed is not very bad?
Is there way to bind the elements of lists to values? Say I have a list, x, that I know is 4 elements long, can do I something like: let ele1,ele2,ele3,ele4 = x ?
I guess the problem is for the compiler to also know the list is 4 elements long
@kreutz looks very perlish ;-) I guess you could write a class with 4 properties and do it in a constructor or use a record type with a builder functio
Ehhh, yeah it's a bit messy. I'm parsing some csv into a function call, and that's why i need the variables separated. I'll just do it the naive way then.
Cross post from twitter: Writing a blog on #fsharp readability in conjunction with the launch of my new PluralSight course. What are your F# readability bug-bears?
If you know that number of elements at design time: let list = [1; 3; 5; 9] let e1, e2, e3, e4 = match list with | [a; b; c; d] -> a, b, c, d | _ -> failwith "Invalid list"
$$$ Shameless commercial plug $$$ - My F# Functional Data Structures course is now live on PluralSight www.pluralsight-training.net (search for my name: 'Eason').
@JKS IMO - don't start with a server. Start by learning the languages and the .NET platform. Only then can you start with the decision making around something as ambitious as (any kind of) server.
have a look at this example: gist.github.com/panesofglass/765088 - then consider how much you have understood or not understood - is this more a raw TCP server or based on Web Sockets or another protocol?
maybe it is related to my own path from heaven to hell today - was trying to implement sftp via winscp today - got winscp working with ease, but totally failed in f# because the thrown exception is b..shit, but now I am locked from accessing the sftp - most likely they have blocked me - at least for a day
it was always complaining about the authentication method, but the real problem was that I mistyped the path for the private key - such a bugger
@7sharp9 Yep, a nice library is what I need (clojure/plumbing |> fhsarpized) but still too amateur to start by myself. But If I manage to get a little POC working I may start one.
So, this isn't really F#, per se, but does anyone know how to use System.Diagnostics.Process to launch a background job (a là appending an & in the terminal)?
Ignore my last question... it seems that's the default behavior on OS X