Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1. Re:  type problems with my little code (raffa f)
   2.  How do I return Nothing from a function? (KC)
   3.  How do I return Nothing from a function? (KC)
   4. Re:  How do I return Nothing from a function? (Norbert Melzer)
   5. Re:  How do I return Nothing from a function? (Darren Grant)
   6. Re:  How do I return Nothing from a function? (Kyle Murphy)
   7.  Haddock and XML (Emanuel Koczwara)


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

Message: 1
Date: Mon, 21 Apr 2014 11:02:48 -0300
From: raffa f <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] type problems with my little code
Message-ID:
        <cahdwbels_3mwxumaux2ml_wy7-48c-axd-namlqctzgmyjq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

thanks for everyone that replied! you all sound really nice. removing the
type info from pack' worked, i hadn't thought of that because i believed
that when pattern matching you always had to write the type info
first. the ScopedTypeVariables
thing sounds really interesting too, and i'm gonna read more about it and
maybe i'll understand more how types work.

and gesh, thanks for the comments on the rest of my code, it's always nice
learning new and useful functions. and i did realize that pack repeats the
same list for every element in the list, but i had written just before that
a function that takes care of repeated elements in a list, so now my final
code just applies that function to pack. i don't know how efficient that
is, but it works!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/33c886cf/attachment-0001.html>

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

Message: 2
Date: Mon, 21 Apr 2014 10:50:34 -0700
From: KC <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] How do I return Nothing from a function?
Message-ID:
        <CAMLKXy=avjtqrd9095cq6csyrvt4fpzpaplulqqofjoxpbr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

-- 

--

Sent from an expensive device which will be obsolete in a few months! :D
Casey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/40dd4d72/attachment-0001.html>

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

Message: 3
Date: Mon, 21 Apr 2014 10:53:31 -0700
From: KC <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] How do I return Nothing from a function?
Message-ID:
        <CAMLKXy=tbvgedk6glehceaqjylcpviqj+_owmuyb3fob5p7...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

How do I return Nothing from a function?

When there is no edge in the graph this code fails.
*** Exception: Graph.hs:65:9-26: Irrefutable pattern failed for pattern
(Data.Maybe.Just w)


*Main> :t weight
weight
  :: (Ix t1, Ix t2) => t1 -> t2 -> Array (t1, t2) (Maybe t) -> t

weight x y g = w
    where
        (Just w) = g!(x,y)


Thank you for your time.

-- 

--

Sent from an expensive device which will be obsolete in a few months! :D
Casey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/afb396e0/attachment-0001.html>

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

Message: 4
Date: Mon, 21 Apr 2014 20:23:44 +0200
From: Norbert Melzer <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How do I return Nothing from a
        function?
Message-ID:
        <ca+bcvstd8myr2pkc8owgwft8tasu-m9v_msrb8mv-wd8sob...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

You can't return Nothing, because your function doesn't return a maybe. If
you make it a maybe, you just need to return the value of g without further
processing.
Am 21.04.2014 19:53 schrieb "KC" <[email protected]>:

> How do I return Nothing from a function?
>
> When there is no edge in the graph this code fails.
> *** Exception: Graph.hs:65:9-26: Irrefutable pattern failed for pattern
> (Data.Maybe.Just w)
>
>
> *Main> :t weight
> weight
>   :: (Ix t1, Ix t2) => t1 -> t2 -> Array (t1, t2) (Maybe t) -> t
>
> weight x y g = w
>     where
>         (Just w) = g!(x,y)
>
>
> Thank you for your time.
>
> --
>
> --
>
> Sent from an expensive device which will be obsolete in a few months! :D
> Casey
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/dfe0c982/attachment-0001.html>

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

Message: 5
Date: Mon, 21 Apr 2014 11:25:24 -0700
From: Darren Grant <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: Re: [Haskell-beginners] How do I return Nothing from a
        function?
Message-ID:
        <ca+9vpffk+l7lofkf8erobv_eqqkqyrmdxovr51tw+d42zfs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If the result of weight is (Maybe t) instead of the then the result of the
array lookup can be passed out directly for the caller to check:

weight x y g = g!(x, y)

Is this what you mean?

Cheers,
Darren
On Apr 21, 2014 10:53 AM, "KC" <[email protected]> wrote:

> How do I return Nothing from a function?
>
> When there is no edge in the graph this code fails.
> *** Exception: Graph.hs:65:9-26: Irrefutable pattern failed for pattern
> (Data.Maybe.Just w)
>
>
> *Main> :t weight
> weight
>   :: (Ix t1, Ix t2) => t1 -> t2 -> Array (t1, t2) (Maybe t) -> t
>
> weight x y g = w
>     where
>         (Just w) = g!(x,y)
>
>
> Thank you for your time.
>
> --
>
> --
>
> Sent from an expensive device which will be obsolete in a few months! :D
> Casey
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/6b7d2de9/attachment-0001.html>

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

Message: 6
Date: Mon, 21 Apr 2014 14:30:50 -0400
From: Kyle Murphy <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How do I return Nothing from a
        function?
Message-ID:
        <ca+y6jcw3kp1+ibcom8u2ez7la9x6bngstevy+_4b6fm5ehm...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Your problem is that you're explicitly saying that weight can NEVER fail to
return a value, so in the case that you run into a Nothing value you need
to return some default value instead. Alternatively you could change the
signature of weight to instead return a Maybe t type instead. If it's the
former, you need something like:

weight x y g = case g!(x,y) of
  Just w -> w
  Nothing -> 0 -- default weight here

or more idiomatically:

weight x y g = maybe 0 id (g!(x,y))

Not sure if you need the parens around g!(x,y) in that expression, but I
put them in just in case.


-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.


On Mon, Apr 21, 2014 at 1:53 PM, KC <[email protected]> wrote:

> How do I return Nothing from a function?
>
> When there is no edge in the graph this code fails.
> *** Exception: Graph.hs:65:9-26: Irrefutable pattern failed for pattern
> (Data.Maybe.Just w)
>
>
> *Main> :t weight
> weight
>   :: (Ix t1, Ix t2) => t1 -> t2 -> Array (t1, t2) (Maybe t) -> t
>
> weight x y g = w
>     where
>         (Just w) = g!(x,y)
>
>
> Thank you for your time.
>
>
> --
>
> --
>
> Sent from an expensive device which will be obsolete in a few months! :D
> Casey
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/65f63d68/attachment-0001.html>

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

Message: 7
Date: Mon, 21 Apr 2014 21:08:52 +0200
From: Emanuel Koczwara <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Haddock and XML
Message-ID: <1398107332.5327.24.camel@emanuel-laptop>
Content-Type: text/plain; charset="utf-8"

Hi,

I want to include some XML in documentation produced by haddock. Here is
my simple test case:

http://lpaste.net/103047

I generate the docs like this:

haddock -h Doctest.hs

Can I set some command line options or maybe there are some formatting
options (like '@' in my example) to get this XML rendered correctly?

Emanuel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5185 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140421/91b75e16/attachment.bin>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 70, Issue 41
*****************************************

Reply via email to