You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+83-1Lines changed: 83 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,5 +10,87 @@ This is why I tried to transpile F# to Php the same way Fable does to Javascript
10
10
11
11
Peeble use Fable transforms to parse F# files and create a simpler intermediate representation. It then convert this to a Php model before serializing it to text.
12
12
13
-
## Build it
14
13
14
+
## Quick start
15
+
16
+
You need first to get [dotnet cli installed](https://dotnet.microsoft.com/download).
The result is a inc.php file containing the code converted to Php.
38
+
39
+
As your code will make calls to FSharp.Core functions for standard operations on lists, maps and other system types, you need to include their implementation. Add an include on [FSharp.Core.php](./tree/master/src/FSharp.Core) that will reference other necessary files.
40
+
41
+
## Build
42
+
43
+
On windows, run :
44
+
45
+
./build.cmd
46
+
47
+
On linux:
48
+
49
+
./build.sh
50
+
51
+
## Interop
52
+
53
+
### Records
54
+
55
+
Records are compiled as Php classes with public fields. It implemnents equality by value.
56
+
57
+
### Unions
58
+
59
+
Unions are compiled as a base class and derived classes for each cases, the same way F# does in .Net.
60
+
61
+
### Options
62
+
63
+
Like in Fable, Option are implemented using Php NULL.
64
+
65
+
### Array
66
+
67
+
Peeble use Php Arrays to implement F# arrays. The Array module is called FSharpArray to avoid name clash.
68
+
69
+
### List
70
+
71
+
F# Lists are implemented in FSharpList as a linked list.
72
+
73
+
### Map/Set
74
+
75
+
Peeble comes with FSharp Map and Set implemented with in depth equality.
76
+
77
+
### Emit
78
+
79
+
To call function that have no been defined in F#, create a function with the expeced signature and mark it with the emit attribute to indicate the Php code to emit at the call site:
80
+
81
+
type Php =
82
+
[<Emit("_($0)")>]
83
+
static member translate s = s
84
+
85
+
[<Emit("sprintf(_($0),$1...)")>]
86
+
static member translatef(fmt : string, [<ParamArray>]args : obj[]) = fmt
87
+
88
+
Here calling `Php.translate("Hello")` will generate:
89
+
90
+
_("Hello");
91
+
92
+
## Contributing
93
+
94
+
There are still many functions missing in the Php implementation of FSharp.Core functions. As you discover some functions missing, feel free to submit implementation.
95
+
96
+
If you find expressions that cannot be transpiled by Peeble, please report them an issue, with - if possible - a minimal example for the code that cannot compile and the expected result.
0 commit comments