Fine I can change the name to wrapper no problem, but I do think there are 
cases where you have general types like for example xml and json and 
wrapped in types like html and geojson. I just think we going to be to late 
to realise that the new Unwrap Is As %w is very useful for other types too. 
Like we where to late with the io.File vs io.Writer debate because we 
simple didn't got enough experience with it.

On Wednesday, July 3, 2019 at 5:28:25 AM UTC+2, Michal Strba wrote:
>
> First of all, this is not at all what "monad" means. A monad is a way to 
> express threading of values between computations. A result of one 
> computation gets threaded as an input to the next one, and so on.
>
> Second, what would be the use-case of this other than errors?
>
> On Wed, Jul 3, 2019, 04:52 Gert <gert....@gmail.com <javascript:>> wrote:
>
>> On Wednesday, July 3, 2019 at 3:03:20 AM UTC+2, Gert wrote:
>>>
>>> https://github.com/golang/go/blob/master/src/errors/wrap.go
>>>
>>> What if we replaced all error types in that file with a empty interface 
>>> or a general monad interface? Can we make it work for other types too and 
>>> introduce a new monad package instead a new error package only?
>>>
>>>
>> ```
>> package monad
>>
>> type Monad interface {
>> Unwrap() Monad
>> }
>>
>> func Unwrap(m Monad) Monad {
>> if m != nil {
>> return m.Unwrap()
>> }
>> return nil
>> }
>> ```
>>
>> ```
>> package monad_test
>>
>> import (
>> "monad"
>> "testing"
>> )
>>
>> type monadT struct{ s string }
>>
>> func (m monadT) Unwrap() monad.Monad { return nil }
>>
>> type wrappedT struct {
>> s string
>> m monad.Monad
>> }
>>
>> func (w wrappedT) Unwrap() monad.Monad { return w.m }
>>
>> func TestUnwrap(t *testing.T) {
>> m1 := monadT{"monad"}
>> m2 := wrappedT{"monad wrap", m1}
>>
>> testCases := []struct {
>> m    monad.Monad
>> want monad.Monad
>> }{
>> {nil, nil},
>> {wrappedT{"wrapped", nil}, nil},
>> {m1, nil},
>> {m2, m1},
>> {wrappedT{"wrap 3", m2}, m2},
>> }
>> for _, tc := range testCases {
>> if got := monad.Unwrap(tc.m); got != tc.want {
>> t.Errorf("Unwrap(%v) = %v, want %v", tc.m, got, tc.want)
>> }
>> }
>> }
>> ```
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golan...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/92fe566f-3f18-43a2-91a6-4db21a1ef4ee%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/92fe566f-3f18-43a2-91a6-4db21a1ef4ee%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/56658275-49de-4cac-aeeb-c770b3da5ed4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to