Skip to main content

Questions tagged [monad]

5 votes
1 answer
862 views

Does C# 8 reference type nullability make Option/Result monad obsolete?

As the most common exceptions in my project are NullReferenceExceptions I'm trying to find a way to limit the occurrence of problems with unexpected or unhandled nulls to the minimum. One of the ...
Piotrek's user avatar
  • 161
2 votes
3 answers
958 views

Exceptions vs Monads

I am curious about the utility of something like monads in the C# world. My experience with these kinds of things is mainly through Rust but I'm a dotnet dev for work I was thinking about the ...
Jeremy Farmer's user avatar
0 votes
1 answer
156 views

If we don't use function composition, does Maybe remain a monad?

A monad is a monoid in the category of endofuctors. Category is a set of two things: Set of elements Set of binary operations between these elements. When we talk about the category endofunctors we ...
pro100tom's user avatar
  • 449
2 votes
1 answer
216 views

Struggling to find the relation between a Maybe structure and the endofunctor

Monad is a monoid in the category of endofunctors. Endofunctor is a functor that maps to itself. What does it mean? Well it means that, no matter which element in the set is taken as an input, the ...
pro100tom's user avatar
  • 449
2 votes
2 answers
834 views

What's the value of IO Monad?

When I'm writing code in the form of IO Monad, I wonder what's real value of it.For example I have a function as def something(in: In): IO[Out]; my function is a pure function that **returns an impure ...
tweetingReza's user avatar
0 votes
1 answer
169 views

Imperative parallels to Haskell's Monad operations

Would it be (mostly) correct to say that the following are the parallels to the Haskell Monad operations in the imperative world? Monad's >> ~ C/C++/JavaScript/etc. , operator do expressions ~ C/...
P Varga's user avatar
  • 339
5 votes
1 answer
2k views

FP Free Monad vs OOP Dependency Injection

I've written my first moderately large project in functional style (in F#) and can see the advantages. The main challenge was to achieve the "Onion" architecture i.e. large and "smart" pure core / ...
KolA's user avatar
  • 645
3 votes
1 answer
199 views

How can the `log` function be used for formal verification

In JavaScript I want to create a log function: function log(string) { console.log(string) } Obviously this causes side effects; it prints to the screen. And I have no control over its ...
user10869858's user avatar
2 votes
2 answers
792 views

What's the proper way to think about state monads?

I've been using a functional approach in my programming of late. I know that mutability and state changes are big no nos within the paradigm. I now find myself working with databases and other data ...
Ucenna's user avatar
  • 1,312
17 votes
4 answers
3k views

When programming in Functional style, do you have a single application state that you weave through the application logic?

How do I construct a system that has all of the following: Using pure functions with immutable objects. Only pass into a function data that the function it needs, no more (i.e. no big application ...
Daisha Lynn's user avatar
8 votes
1 answer
319 views

IO Monadic code: standard vs flipped function composition

Below is a line that handles socket connections in a simple Haskell program. mainLoop :: Socket -> IO () mainLoop sock = accept sock >>= forkIO . handle . fst >> mainLoop sock The "...
Michal Charemza's user avatar
3 votes
0 answers
441 views

Clojure: Decomposing Logging, Metrics, and Business Logic from a Function

I was reading the post A Modern Architecture for FP that included a code snippet that the author wanted to decompose further. I don't know Haskell but I recognize enough to know that I've written many ...
MonkeyWithDarts's user avatar
0 votes
3 answers
461 views

Monads in JavaScript

A monad is an object that has: A transformation that takes a type and produces a new type. In C# we call such a transformation a "generic type". We have a generic type M<T>, we have a ...
52d6c6af's user avatar
  • 730
6 votes
4 answers
2k views

Minimal programmer's definition of a monad

I am trying to formulate a definition of a monad without needing mathematical terms or Haskell to understand. Can a monad be thought of as a function that accepts a value and wraps it such that it ...
52d6c6af's user avatar
  • 730
20 votes
1 answer
9k views

What is a Comonad and how are they useful?

Recently I've been dusting off my knowledge on how Monads work. I've also been introduced to the concept of a 'Comonad', which is described as the inverse dual of a monad. However, I am impossible to ...
Qqwy's user avatar
  • 4,937

15 30 50 per page