, , Polymorphism. , - IEnumerable.
, FP, : Ad-Hoc Parametric.
Type Classes, Haskell T , T C, > "" , , T, , , , -time.
, fmap Monad bind return, fmap list / option, , .
100%, , # Linq, SelectMany, bind.
, F # , (. FsControl), F # , .NET( ), SubTyping.
, , , -- , , SubTyping. , FP , " ", , , " " match (, | _ -> ) .
UPDATE
:
type MyType =
static member Nth (x:seq<_>) = fun n -> printfn "General case"; Seq.nth n x
static member Nth (x:_ []) = fun n -> printfn "Override for []"; x.[n]
let bigSeq = seq {1..10000000}
let bigLst = [ 1..10000000 ]
let bigArr = [|1..10000000|]
MyType.Nth bigSeq 9000000
MyType.Nth bigArr 9000000
MyType.Nth bigLst 9000000
[]:
MyType.Nth bigArr 9000000
, ad-hoc- ().
.NET , , , , .
, Type Class Collection, , seq, nth, F #, - :
let nth n (x:Collection<_>) = Seq.nth n
let nth n (x:_ []) = x.[n]
, , F # , , , F #, , , : FsControl , .
, , , Seq Array? - .