Follow the Unison Programming Language Guide
Use the Unison programming language for all code unless otherwise specified.
Use the following procedure to assist me with writing code.
| open System.IO | |
| let lines = File.ReadAllLines "references.fsx" | |
| let fixedLines = lines |> Array.map (fun line -> | |
| if line.StartsWith("#r") then | |
| if line.Contains("/usr/share/dotnet/packs/") then | |
| line.Replace("/packs/", "/shared/") | |
| .Replace(".Ref/","/") | |
| .Replace("/ref/net8.0/", "/") |
| #r "nuget: Fli" | |
| open Fli | |
| open System | |
| open System | |
| let isHelpRequested = fsi.CommandLineArgs |> Seq.contains "--h" | |
| [<Literal>] |
| #r "nuget: NodaMoney" | |
| open NodaMoney | |
| open System | |
| open System.Threading.Tasks | |
| module Products = | |
| type Product = | |
| | Shoes | |
| | Skirt |
| type MyType = | |
| | MyCase | |
| static member statFun x = match x with MyCase -> "I'm static member function!" | |
| static member statFunUnit () = "I'm static member function with unit param!" | |
| static member statFunGeneric (x, y) = | |
| match x with MyCase -> $"I'm static member function with generic param with value = %O{y}!" | |
| static member statProp = "I'm static member property!" | |
| member this.objProp = match this with MyCase -> "I'm object member property!" | |
| member this.objFunGen x = match this with MyCase -> $"I'm object member function with param with value = %O{x}!" | |
| member this.objFunUnit () = match this with MyCase -> "I'm object member function with unit param!" |
| (* | |
| An exercise in modeling. Users can be verified or banned. A user can be banned only if their username is "offensive". | |
| We assume the Onion architecture. Modules `User` and `Verification` belong to the model. Module `UserVerification` | |
| belongs to the application layer. Data access layer is omitted completely; it should be fairly trivial. | |
| Note that the verified/banned aspect of a user is modeled "externally" to the notion of user itself. In particular, | |
| there are no "aggregates" below which combine all aspects of a user. | |
| *) |
| module rec Dat | |
| open Browser.Types | |
| open Fable.Core | |
| open System | |
| [<ImportAll("dat.gui")>] | |
| let exports: IExports = jsNative | |
| [<AllowNullLiteral>] |
| // SRTP: Statically Resolved Type Parameters | |
| // https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters | |
| // SRTP Allows for pulling members out of types that where the member is named and typed the same | |
| // In this example SRTP will be used to pull out the 'First: string' and 'Last: string' members | |
| // from different types | |
| // One example of SRTP in the F# Base Class Library is the (+) operator. | |
| // You'll see that it has this type signature: |
| #r "nuget:Microsoft.ML" | |
| #r "nuget:Microsoft.ML.OnnxRuntime" | |
| #r "nuget:Microsoft.ML.OnnxTransformer" | |
| #r "nuget:Microsoft.ML.ImageAnalytics" | |
| #r "nuget:System.Drawing.Common" | |
| open System.IO | |
| open System.Drawing | |
| open Microsoft.ML | |
| open Microsoft.ML.Data |