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
Do we need options? Here some ideas for nullables. Having option type might be not a good idea, beacuse it's definitely incompatible with both C#'s nullables and F#'s options.
But we probably cannot depend on FSharp.Core, so we either do nullables (which aren't so good when working with old BCL or 3rd party API) or we do our own option. Or...?
Regardless of what we choose, I'm going to use Option<T> as if we already decided what it is.
Sequences
Type Seq<T>
We can write our own API and back it with Linq whenever possible.
map : (T -> U) -> Seq<T> -> Seq<U>
where : (T -> Bool) -> Seq<T> -> Seq<T>
flatten : (T -> Seq<U>) -> Seq<T> -> Seq<U>
fold : (T * A -> A) -> A -> Seq<T> -> A
append : T -> Seq<T> -> Seq<T>
prepend : T -> Seq<T> -> Seq<T>
product : Seq<T1> * Seq<T2> -> Seq<T1 * T2>
product : Seq<T1> * Seq<T2> * Seq<T3> -> Seq<T1 * T2 * T3>
// potentially auto-generated overloads for product for any number of type arg
zip : Seq<T1> * Seq<T2> -> Seq<T1 * T2>
zip : Seq<T1> * Seq<T2> * Seq<T3> -> Seq<T1 * T2 * T3>
// potentially auto-generated overloads for zip for any number of type arg
Singly linked list
type FreshList<T> =
| Nil
| Cons(Element, FreshList<T>)
However since it's not functional-first language, I don't think we want to replace List<T> with this one. Should we choose another name?
Map
type FreshMap<TKey, TValue> =
...
member Add : TKey * TValue -> FreshMap<TKey, TValue>
member Remove : TKey * TValue -> FreshMap<TKey, TValue>
member Item : TKey -> TValue
member TryGet : TKey -> Option<TValue>
Set
type FreshSet<T> =
...
member Add : T -> FreshSet<T>
member Remove : T -> FreshSet<T>
The text was updated successfully, but these errors were encountered:
Option
Do we need options? Here some ideas for nullables. Having option type might be not a good idea, beacuse it's definitely incompatible with both C#'s nullables and F#'s options.
But we probably cannot depend on
FSharp.Core
, so we either do nullables (which aren't so good when working with old BCL or 3rd party API) or we do our own option. Or...?Regardless of what we choose, I'm going to use
Option<T>
as if we already decided what it is.Sequences
We can write our own API and back it with Linq whenever possible.
Singly linked list
However since it's not functional-first language, I don't think we want to replace
List<T>
with this one. Should we choose another name?Map
Set
The text was updated successfully, but these errors were encountered: