Great article! Here are another couple simple examples showing the advantages of fp-ts's strong type paradigms:
importsortByfrom'lodash/sortBy'import{flow,map,takeRight}from'lodash/fp'import{pipe}from'fp-ts/function'import*asAfrom'fp-ts/ReadonlyArray'import*asOrdfrom'fp-ts/Ord'import*asNfrom'fp-ts/number'interfaceResult{rank:number;value:string}declareconstresults:Result[]constlodashSort=sortBy(results,'ranck')// <-- no type errorconstfptsSort=pipe(results,A.sort(pipe(N.Ord,Ord.contramap((b:Result)=>b.ranck)// <-- type error)))constlodashFlow=flow(map((r)=>r.rank+3),// <-- type error: Object is of type 'unknown'takeRight(2),)(results)constfptsPipe=pipe(results,A.map((r)=>r.rank+3),// <-- no type errorA.takeRight(2))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article! Here are another couple simple examples showing the advantages of fp-ts's strong type paradigms: