i learning f# free online resource. since curious , try apply learned stuff in small excercises, find myself consulting msdn f# documentation quite often.
but documentation seems cryptic me. take documentation page pown function example. usage pretty straight forward, don't understand functions signature:
// signature: pown : ^t -> int -> ^t (requires ^t static member 1 , ^t static member op_multiply , ^t static member (/)) can explain me, following things about?
- what ^ (circumflex) before t do?
- what "t" mean? generic type?
- what double -> do?
- what requires statements do?
i hope isn't cover in 1 answer.
- this indicates
tstatically resolved type parameter opposed normal generic type parameter (see 4 below). - yes.
->type constructor functions , right associative, part equivalent^t -> (int -> ^t). in other words, if pass argument of type^tfunction, you'll functionint^t.pown 2function 2x power hasn't been passed yet. ,pown 2 8same(pown 2) 8: it's 28.- at point of invocation, whatever concrete type substituted
^tmust statically known meet these requirements. can callpown 2 8(becauseintsupports these operations), notpown "test" 8(becausestringdoesn't).
Comments
Post a Comment