[Haskell-beginners] Trouble understanding the type of sequence [Just, Just]
Mihai Maruseac
mihai.maruseac at gmail.com
Sat Dec 12 20:36:18 UTC 2015
Hi,
Maybe is a type and Just is one of it's constructors (the other being Nothing):
> data Maybe a = Just a | Nothing
On Sat, Dec 12, 2015 at 3:29 PM, Lim H. <limdauto at gmail.com> wrote:
> Hi everyone,
>
> Sorry if this email disturbs you. I haven't used a developer's mailing list
> before so I'm not sure if I'm violating any etiquette. If I do, please
> excuse me.
>
> I'm trying to understand the type of sequence [Just, Just]. I can understand
> sequence [Just 1, Just 2] :: Num a => Maybe [a]
>
> because when looking at the type of sequence
>
> sequence :: (Monad m, Traversable t) => t (m a) -> m (t a)
>
> it is clear that this function takes a collection of monadic values and
> return a single monadic value of the collection. Thus, when we call sequence
> [Just 1, Just 2] we should get back a Just of [1,2]. Following that train of
> thoughts, shouldn't sequence [Just, Just] return a single Just?
>
> Here is the corresponding SO question
>
> http://stackoverflow.com/questions/34244574/trouble-understanding-the-type-of-sequence-just-just
>
> Lim
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
--
Mihai Maruseac (MM)
"If you can't solve a problem, then there's an easier problem you can
solve: find it." -- George Polya
More information about the Beginners
mailing list