Simplee.Common
1.0.13
dotnet add package Simplee.Common --version 1.0.13
NuGet\Install-Package Simplee.Common -Version 1.0.13
<PackageReference Include="Simplee.Common" Version="1.0.13" />
paket add Simplee.Common --version 1.0.13
#r "nuget: Simplee.Common, 1.0.13"
// Install Simplee.Common as a Cake Addin #addin nuget:?package=Simplee.Common&version=1.0.13 // Install Simplee.Common as a Cake Tool #tool nuget:?package=Simplee.Common&version=1.0.13
Simplee.Common
Library Simplee.Common v1.0.13 implements common functionality used by all other Simple projects. The namespace of the library is Simplee.
open Simplee
Here is the main functionality exposed:
- Active patterns
- Error types
- Result monad
Find below more details about each class of functionality.
1. Active Patterns
The library implements different partial and complete active patterns:
1.1. Collections
You can use the following partial active patterns:
- MemberOf, NotMemberOf - these partial patterns determine if a given item is a member of a given collection.
- SeqDoesContain, SeqNotContains - these partial patterns determine whether a given collection contains or not a given item.
let is2Or3 = function
| MemberOf [2;3] -> "x is a member of the collection"
| _ -> "x is not a member of the collection"
let doesContain2 = function
| SeqContains 2 true -> "ns does contain the item 2"
| _ -> "ns does not contain the item 2"
1.2. Compare
You can use the following partial active patterns: EqualToN, LessThanN, LessOrEqualToN, GreaterThanN, GreaterOrEqualThanN.
let isSmallerThan4 = function
| LessThanN 4 -> "n is less than 4"
| _ -> "n is greater or equal than 4"
1.3. Numerals
There are couple of classes of active patterns related to numerals:
- Negative, NegativeOrZero, Positive, PositiveOrZero - these partial patters compare a given number to 0.
- Even|Odd - the complete pattern determines whether a given number is even or odd.
- IsMultipleOfN - this partial pattern determine whether a given number if a multiple of a given pivot N. The library exposes several convenience partial patterns for specific pivot values: IsMultipleOf2, IsMultipleOf3, IsMultipleOf4, IsMultipleOf8, IsMultipleOf10, IsMultipleOf16.
let isMultipleOf2 = function
| IsMultipleOf2 -> "n is multiple of 2"
| _ -> "n is not multiple of 2"
let isMultipleOf80 = functions
| IsMultipleOf8 & IsMultipleOf10 -> "n is multiple of 8 and 10"
| _ -> "n is not multiple of both 8 and 10"
1.3. String
The library exposes couple of classes of active patterns related to string:
- IsNullOrWhite, IsAllCaps, IndexOf, StartsWith - the partial pattern determines if a given string is null or empty or if the string has only CAPS.
- Parsing patterns - these partial patterns can be used in order to attempt parsing a given string and get an integer, or a bool, or a Date value. The patterns are: IsInt, IsBool, IsDate.
let strToInt = function
| IsInt n -> "The input string is an integer"
| _ -> "The input string is not an integer"
2. Error Types
The library implements an error type which is used by all other Simple projects. The error can encapsulate any properties (operates as a property bag).
/// The property attached to an error
type ErrProperty =
| ErrProperty of nm:string * v:ErrValue
/// The error is a property bag.
type SError =
| ErrSuccess of id:ErrId * props:ErrProperty list
| ErrWarning of id:ErrId * props:ErrProperty list
| ErrError of id:ErrId * props:ErrProperty list
| ErrCritical of id:ErrId * props:ErrProperty list
The library exposes several convenience functions which allow the user create error or success instances.
let e =
1
|> eid "AREA" // the error identifier (area & id)
|> err // create an error
|> erraddkid "corr123" // adds the correlation id
|> erraddloc __SOURCE_FILE__ __LINE__ // adds the location
|> erraddmsg "testing" // adds a message
// To get the string representation of an error call err2str
e |> err2str
3. Result Monad
The library exposes several convenience function which can help matching the results: isROk, isRErr. This functions match the active patterns: |IsROk| and |IsRErr|.
Also you can find couple convenience function which extract the value from success results and error from failure results: r2val and r2err
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- FSharp.Core (>= 4.3.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Simplee.Common:
Package | Downloads |
---|---|
Simplee.Goa
Lambda calculus implementation using FSharp. The library exposes the classic combinators, boolean algebra, numeral agebra using Church numerals, pairs algebra. Combinators: S, K, I, M, KI, C, B, Th, B1, V Boolean: GTrue, GFalse, GAnd, GOr, GBeq Numerals: G0, G1, G2, GSucc, GPred, GAdd, GSum, GMul, GPow, LEq, Eq, Gr Pairs: GPair, GFst, GSnd, GPhi |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.13 | 1,381 | 3/18/2018 | |
1.0.12 | 1,253 | 3/15/2018 | |
1.0.11 | 2,431 | 3/2/2018 | |
1.0.10 | 1,462 | 3/1/2018 | |
1.0.9 | 1,416 | 2/27/2018 | |
1.0.8 | 1,443 | 2/27/2018 | |
1.0.7 | 1,309 | 2/26/2018 | |
1.0.6 | 1,362 | 2/26/2018 | |
1.0.5 | 1,294 | 2/21/2018 | |
1.0.4 | 1,299 | 2/11/2018 | |
1.0.3 | 1,359 | 2/11/2018 | |
1.0.2 | 2,215 | 1/29/2018 | |
1.0.1 | 1,367 | 1/26/2018 | |
1.0.0 | 1,310 | 1/26/2018 |
Added list to string function.