57 Matching Annotations
- Dec 2022
-
www.zhihu.com www.zhihu.com
-
如何理解 Free Monad?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
该如何理解Monad?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
如何理解 Extensible Effects?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
如何解释 Haskell 中的单子(Monad)?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
怎么理解“一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已”?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
怎样用简单的语言解释 monad?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
如何理解Monad Transformer?有哪些资料可以帮助理解它?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
state monad 为什么wrap的是一个 Function ?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
为什么applicative不定义为monoid的子类?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
List的Applicative instance应该怎么写?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
Haskell引入Applicative functor有什么意义?
Tags
Annotators
URL
-
- Mar 2021
-
trailblazer.to trailblazer.to
-
endpoint Diagram::Operation::Create do |ctx, **| redirect_to diagram_path(ctx[:diagram].id) end.Or do |ctx, **| render :form end
-
-
trailblazer.to trailblazer.to
-
The flow pipetree is a mix of the Either monad and “Railway-oriented programming”, but not entirely the same.
-
- Feb 2021
-
github.com github.com
-
It is based on the idea that each validation is encapsulated by a simple, stateless predicate that receives some input and returns either true or false.
-
It will return the result as a Dry::Monads::Result object which can be either successful or failure.
-
-
github.com github.com
-
Or you can use Maybe container! It consists of Some and Nothing types, representing existing state and empty (instead of None) state respectively.
-
-
sobolevn.me sobolevn.me
-
Let’s start with the same number dividing example, which returns 0 when the error happens. Maybe instead we can indicate that the result was not successful without any explicit numerical value?
-
Now you can easily spot them! The rule is: if you see a Result it means that this function can throw an exception. And you even know its type in advance.
-
You can use container values, that wraps actual success or error value into a thin wrapper with utility methods to work with this value. That’s exactly why we have created @dry-python/returns project. So you can make your functions return something meaningful, typed, and safe.
-
-
www.morozov.is www.morozov.is
-
This is how the same example would look like using raw monads:
-
Do notation provides an alternative to bind, which also flattens the code.
-
bind applies unwrapped Success value to the block, which should return a Result object. No-op on Failure
-
-
Railway Oriented Programming comes from functional programming, so it is tightly related to the usual FP concepts like monads, composition, and many others.
-
-
en.wikipedia.org en.wikipedia.org
-
Though rarer in computer science, one can use category theory directly, which defines a monad as a functor with two additional natural transformations. So to begin, a structure requires a higher-order function (or "functional") named map to qualify as a functor:
rare in computer science using category theory directly in computer science What other areas of math can be used / are rare to use directly in computer science?
-
can transform monadic values m a applying f to the unwrapped value a
-
In fact, the Product comonad is just the dual of the Writer monad and effectively the same as the Reader monad (both discussed below)
-
procedure to wrap values of any basic type within the monad (yielding a monadic value)
-
A combinator, typically called bind (as in binding a variable) and represented with an infix operator >>=, that unwraps a monadic variable, then inserts it into a monadic function/expression, resulting in a new monadic value:(mx >>= f) : (M T, T → M U) → M U
-
A type constructor M that builds up a monadic type M T
-
A type converter, often called unit or return, that embeds an object x in the monad:.mw-parser-output .block-indent{padding-left:3em;padding-right:0;overflow:hidden}unit(x) : T → M T
-
allows monads to simplify a wide range of problems
-
another to compose functions that output monadic values (called monadic functions)
-
Monads achieve this by providing their own data type (a particular type for each type of monad), which represents a specific form of computation
-
In functional programming, a monad is an abstraction that allows structuring programs generically
-
Supporting languages may use monads to abstract away boilerplate code needed by the program logic.
-
Whatever language or default programming paradigm a developer uses, following the monad pattern brings many of the benefits of purely functional programming.
-
By reifying a specific kind of computation, a monad not only encapsulates the tedious details of that computational pattern, but it does so in a declarative way, improving the code's clarity.
-
Maybe T can be understood as a "wrapping" type, wrapping the type T into a new type with built-in exception handling
-
Since monads make semantics explicit for a kind of computation, they can also be used to implement convenient language features.
-
Research beginning in the late 1980s and early 1990s established that monads could bring seemingly disparate computer-science problems under a unified, functional model.
-
handling potential undefined values (with the Maybe monad)
Tags
- dual (math)
- representing a kind of computation (monad)
- monad: wrapping value (nomadic value)
- unification/cohesiveness
- error/exception handling
- wrapping type
- declarative
- monad: monadic functions (composition)
- functor
- reduce the amount of boilerplate/duplication
- monad: unwrapping
- annotation meta: may need new tag
- category theory
- monad: data type
- use case
- clarity
- simplify
- encapsulation
- code/program structure
- generic programming
- reifying
- monad: Maybe
- abstractions
- programming paradigm
- advantages/merits/pros
- higher-order function
- functional programming
- semantics
- _any_
- defining in terms of _
- monad: monadic value (wrapping a value within the monad)
- monad
Annotators
URL
-
-
dry-rb.org dry-rb.org
-
To get the final value you can use value_or which is a safe way to unwrap a nil-able value.
-
In other words, once you've used Maybe you cannot hit nil with a missing method. This is remarkable because even &. doesn't save you from omitting || "No state" at the end of the computation. Basically, that's what they call "Type Safety".
-
-
Monads provide an elegant way of handling errors, exceptions and chaining functions so that the code is much more understandable and has all the error handling, without all the ifs and elses.
Tags
- good explanation
- good point
- type safety
- chaining
- understandable
- nullable type/value
- monad: Maybe
- error/exception handling
- too many ifs: bad
- elegant solution
- make it impossible to get wrong/incorrect
- ruby library
- remarkable
- optional chaining/safe navigation operator
- monad: unwrapping
- dry-monads (Ruby)
- monad
Annotators
URL
-
-
jrsinclair.com jrsinclair.com
-
-
In this article, we’ll take a look at using the ‘Either monad’ as an alternative to try...catch.
-
And a word of warning. If you haven’t come across things like monads before, they might seem really… different. Working with tools like these takes a mind shift. And that can be hard work to start with.
-
-
functionalprogramming.medium.com functionalprogramming.medium.com
-
mmhaskell.com mmhaskell.com
-
The IO monad wraps computations in the following context: "This computation can read information from or write information to the terminal, file system, operating system, and/or network". If you want to get user input, print a message to the user, read information from a file, or make a network call, you'll need to do so within the IO Monad. These are "side effects". We cannot perform them from "pure" Haskell code.
-
A Monad wraps a value or a computation with a particular context. A monad must define both a means of wrapping normal values in the context, and a way of combining computations within the context.
-
-
-
wiki.haskell.org wiki.haskell.org
-
-
rosettacode.org rosettacode.org
Tags
Annotators
URL
-
-
blog.logrocket.com blog.logrocket.com
-
This style of error handling uses monadic behavior — a substitute way of handling errors.
-
- Jan 2020