?- S = "the|little|brown|fox|lost|its|way", split_string(S,"|","",Strings), maplist(string_length,Strings,Lengths), list_to_set(Lengths,Set).
S = "the|little|brown|fox|lost|its|way",
Strings = ["the", "little", "brown", "fox", "lost", "its", "way"],
Lengths = [3, 6, 5, 3, 4, 3, 3],
Set = [3, 6, 5, 4].
apt-get update && apt-get install -y gcc | |
mkbundle --simple --machine-config /etc/mono/4.5/machine.config --config /etc/mono/config -L /usr/lib/mono/4.5 --library /usr/lib/libmono-btls-shared.so -o paket paket.exe |
$ brew install nsd | |
==> Installing dependencies for nsd: openssl, libevent | |
==> Installing nsd dependency: openssl | |
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierr | |
######################################################################## 100.0% | |
==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz | |
==> Caveats | |
A CA file has been bootstrapped using certificates from the SystemRoots | |
keychain. To add additional certificates (e.g. the certificates added in | |
the System keychain), place .pem files in |
?- use_module(library(http/json_convert)). | |
true. | |
?- json:atom_json_term('{"foo":"bar"}',T, []), T=json(J), J.foo=Bar. | |
T = json([foo=bar]), | |
J = [foo=bar], | |
Bar = bar. |
#!/bin/bash | |
dotnet new console -n littleSuaveApp -lang F#; | |
cd littleSuaveApp; | |
dotnet add package suave; | |
awk '/open System/{print "open Suave"}; /0/{print " startWebServer { defaultConfig with bindings = [ HttpBinding.createSimple HTTP \"0.0.0.0\" 8080 ] } (Successful.OK \"Hello World!\")"}1' Program.fs > tmp.fs; | |
mv tmp.fs Program.fs; | |
dotnet publish -c Release; |
--- | |
- hosts: all | |
tasks: | |
- name: Download MS product repository | |
get_url: | |
url: https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb | |
dest: /tmp/packages-microsoft-prod.deb | |
- name: Install MS product repository | |
apt: deb=/tmp/packages-microsoft-prod.deb | |
become: true |
Suave and Giraffe are functional web frameworks that work based on composition of handlers. A handler is a function that accepts an HttpContext
and returns an Async<HttpContext option>
, fitting nicely into an HTTP server's protocol of accepting HTTP messages with a request and some metadata, then returning a message with that metadata and a response. This makes the WebPart
in Suave, for example.
While the frameworks themselves only allow you to put a WebPart
into the processing pipeline, it is entirely up to you how you compose functions together to get that WebPart
. When you compose WebPart A and WebPart B (or HttpHandler A and HttpHandler B), you are using the a compose
operator - >=>
. Take a look at the function:
let compose (first : 'a -> Async<'b option>) (second : 'b -> Async
Troubleshooting a running application can be difficult, usually it starts around checking log output and then following through the likely code paths to get an idea of where a failure may occur. In a development environment, you might attach a debugger a step through source, but troubleshooting isn't always that convenient. There are several helpful tools that can assist, but one that gives the most comprehensive view of a running application is strace
. With strace
you are able to see all of the system calls an application makes to get a detailed understanding of what is going on "under the hood" in order to troubleshoot an issue.
Take a simple "hello world" F# application, the kind you get from dotnet new console -lang F# -n strace-sample"
. Build it with dotnet build
and then launch it with strace
to get a trace of all the system calls in a file called trace.log
(adjusting for your build output path if on a different framework vers
I came from the OOP world, most of my professional work was in Java or C#. The languages were similar, and I could use them interchangably as I built software in each of them for several years. With enough experience in both, I was comfortable with either ecosystem and could generally be productive in either. Sometimes the job required one or the other. Sometimes the target OS constrained my choice to Java, which frustrated me a bit, because the languages were so similar, why would the runtime try to restrict a choice? I enjoyed writing server applications on Unix in college, and Linux afterwards, because the machines were so easy to configure compared to Windows machines that took a few hours to install and configure to get my software running. On Linux, I could type a handful of commands into a newly installed system and be up and running.
Sometime around 2005, Java had stagnated while C# was flourishing. They both released generics, but then C# came out with new features like