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
# Why we can't have nice things, c# query expression edition
15
15
16
16
The closest thing to f#'s computational expression is either combination of `async``await` keywords in contexts that
17
-
do not always translate to asynchronous context or query expression, which does not always translate to querying something.
17
+
do not always translate to asynchronous context or query expression which does not always translate to querying something.
18
18
19
19
That's because C# is a corporate enterprise language which tries to smuggle Nice Things through, but in a different,
20
20
more corporate-enterprise-like form - not too abstract, sprinkled with "query SQL from code!"-, "Improve responsiveness without big refactors!"-, or similar seasoning.
21
21
22
+
## About query expression
23
+
24
+
[Query expression](https://docs.microsoft.com/en-us/dotnet/csharp/linq/query-expression-basics) is a syntactic sugar which allows compiler to translate
## ...converging into the same topic, never reaching it
123
+
`monad` is from [F#+](http://fsprojects.github.io/FSharpPlus/), though implementing `option` Computation Expression manually is pretty straight-forward
86
124
87
-
These c# constructs do exactly the same thing, without any major or unsafe hacks. The main barrier from using these in a monad-like manner is their naming. Despite being perfectly viable in multiple scenarios their naming suggests using them in LINQ-to-SQL and asynchronous code respectively.
125
+
## ...converging into the same topic, never reaching it
88
126
127
+
These c# constructs do exactly the same thing, without any major or unsafe hacks. The main barrier from using these in a monad-like manner is their naming. Despite being perfectly viable in multiple scenarios their naming suggests using them in LINQ-to-* and asynchronous code respectively.
89
128
90
129
- in c# there's no way to create a generic `Monad<T<E>>` because there's no higher-kinded polymorphism
91
-
- we have poor type inference, no partial inference, can't have
92
-
- query expression has no ability jump from one monad type to another using concise language syntax, while functional languages have transformers and one can nest computational expressions.
93
-
94
-
95
-
## About query expression
96
-
97
-
Query expression is a syntactic sugar which allows compiler to translate
- poor type inference, no partial inference, partly due to complicated inheritance laws
131
+
- query expression has no ability to switch from one monad type to another using concise language syntax, while functional languages have transformers and one can nest computational expressions.
0 commit comments