New answers tagged functional-programming
1 vote
Why explicitly writing a singleton ctor - instead of just _ - is necessary in the context of dependent types?
You haven't really fleshed out your proposal for what this new GHC capability would look like. Are you imagining that GHC would, in the (very!) special case that an ADT or GADT has a single, zero-...
1 vote
Church encoding (lambda calculus) to define < , > , !=
The usual lambda calculus (from now on: LC) way to encode numbers is indeed the Church encoding: 0 = λf. λx. x 1 = λf. λx. f x 2 = λf. λx. f (f x) This notation can be cumbersome to use, though. We ...
2 votes
Is there a feature (pattern synonyms?) to turn a datatype into syntactic sugar for constructing another datatype?
Probably the best you can do with existing technology is to simply convert the pattern match to a runtime error -- rather than a compile-time error. Like this: data Bar = Bar (Bool -> Int -> ...
2 votes
Is there a feature (pattern synonyms?) to turn a datatype into syntactic sugar for constructing another datatype?
To show that sometimes what you ask for is not what you want ... here's a 'solution': {-# LANGUAGE PatternSynonyms, ViewPatterns #-} type Foo = (String, String, String, String) -- override the data ...
1 vote
How can I implement consistent typed error propagation in C# without scattering try/catch across layers?
Both approaches are fine, only if you have Result-type return, you handle the error internally Result public Result<User> GetUser(int id) { try { var user = _repo.Find(id); ...
Top 50 recent answers are included
Related Tags
functional-programming × 19248haskell × 3337
scala × 2925
javascript × 2531
java × 1385
python × 1036
f# × 945
ocaml × 734
recursion × 673
lambda × 664
list × 637
scheme × 628
function × 620
clojure × 605
monads × 597
java-8 × 588
r × 464
arrays × 463
ramda.js × 458
c# × 451
c++ × 442
lisp × 393
types × 388
java-stream × 376
typescript × 367