Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Monoid algebra (Manny Romero)
   2.  Addendum:  Monoid algebra (Manny Romero)
   3.  Clarification (last one!):  Monoid algebra (Manny Romero)
   4.  Lost Monad Signature (Quentin Liu)
   5.  Template Haskell: simple way to "declare" type   and instance (Baa)
   6. Re:  Lost Monad Signature (David McBride)


----------------------------------------------------------------------

Message: 1
Date: Fri, 8 Dec 2017 14:07:02 +0100
From: "Manny Romero" <mannyrom...@mail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Monoid algebra
Message-ID:
        
<trinity-65b4ba29-5b83-4729-aab7-de76e20c34b0-1512738422574@3c-app-mailcom-lxa08>
        
Content-Type: text/plain; charset="utf-8"

An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171208/6e5157a6/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 8 Dec 2017 14:32:59 +0100
From: "Manny Romero" <mannyrom...@mail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Addendum:  Monoid algebra
Message-ID:
        
<trinity-4e095300-a2e9-44e5-86fd-c18e09452612-1512739979176@3c-app-mailcom-lxa08>
        
Content-Type: text/plain; charset="utf-8"

An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171208/a9117bd5/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 8 Dec 2017 14:36:46 +0100
From: "Manny Romero" <mannyrom...@mail.com>
To: beginners@haskell.org
Cc: beginners@haskell.org
Subject: [Haskell-beginners] Clarification (last one!):  Monoid
        algebra
Message-ID:
        
<trinity-61d434e8-430a-4c78-87d9-3da2f00caded-1512740206092@3c-app-mailcom-lxa08>
        
Content-Type: text/plain; charset="utf-8"

An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171208/a8f5f5d7/attachment-0001.html>

------------------------------

Message: 4
Date: Fri, 8 Dec 2017 10:37:23 -0500
From: Quentin Liu <quentin.liu.0...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Lost Monad Signature
Message-ID: <bde7c016-6a35-45e0-a996-6e183524fcfa@Spark>
Content-Type: text/plain; charset="utf-8"

Hi,

The function `join` flattens a double-layered monad into one layer and its type 
signature is

  join :: (Monad m) => m (m a) -> m a

But when the first argument supplied is `(,)`, the type signature becomes

  join (,) :: b -> (b, b)

in ghci. The monad constraint is lost when supplied the first argument. So my 
question is why the type constraint is lost and what monad is supplied here.

Regards,
Qingbo Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171208/21dc6445/attachment-0001.html>

------------------------------

Message: 5
Date: Fri, 8 Dec 2017 19:38:19 +0200
From: Baa <aqua...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Template Haskell: simple way to "declare"
        type    and instance
Message-ID: <20171208193819.4f54fed3@Pavel>
Content-Type: text/plain; charset=US-ASCII

Hello, All!

Is any way similar to templates (like in Crystal language, Rust, etc)
to create `data X = ...`, `instance Show ...`, etc in TH? I found this
tutorial https://wiki.haskell.org/A_practical_Template_Haskell_Tutorial
but all looks complicated. Or something like Lisp macros, may be some
modern library? Like quasy-quotations but for `data` and `instance`
declarations (I don't know is it possible even) ?

===
Best regards, Paul


------------------------------

Message: 6
Date: Fri, 8 Dec 2017 13:10:49 -0500
From: David McBride <toa...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Lost Monad Signature
Message-ID:
        <can+tr40-jqjkuu78mimadqe_qols4akth+zi-0bxujo5dbo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If you type :i Monad in ghci, you will see this instance

instance Monad ((->) r)

What this means is a function where the first argument is of type 'r'... is
a monad.  You can in fact use do notation / return on a tuple to manipulate
its second argument monadically.

So let's look at what that does to the type signature of join when 'm' is
((->) b)

join :: Monad m => m (m a) -> m a

 -- m = ((->) b)

join :: ((->) b ((->) b a)) -> (((->) b a))

Now we just have to move the arrows from prefix to infix.  Let's do it step
by step.

join :: ((->) b (b -> a)) -> (b -> a)
join :: (b -> (b -> a)) -> (b -> a)

x -> (y -> z) is equivalent to x -> y -> z

join :: (b -> b -> a) -> (b -> a)
join :: (b -> b -> a) -> b -> a

So now when you put an operator into it that takes two arguments

(,) :: a -> b -> (a,b)

You get the type you saw.

join (,) :: b -> (b, b)





On Fri, Dec 8, 2017 at 10:37 AM, Quentin Liu <quentin.liu.0...@gmail.com>
wrote:

> Hi,
>
> The function `join` flattens a double-layered monad into one layer and its
> type signature is
>
> join :: (Monad m) => m (m a) -> m a
>
> But when the first argument supplied is `(,)`, the type signature becomes
>
> join (,) :: b -> (b, b)
>
> in ghci. The monad constraint is lost when supplied the first argument. So
> my question is why the type constraint is lost and what monad is supplied
> here.
>
> Regards,
> Qingbo Liu
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20171208/02a348a0/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 114, Issue 10
******************************************

Reply via email to