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.  GHCi error msgs (Julius Gedvilas)
   2. Re:  GHCi error msgs (Karolis Velicka)
   3. Re:  GHCi error msgs (Julius Gedvilas)
   4.  Question on syntax (Rohit Sharma)
   5. Re:  Question on syntax (Bob Ippolito)
   6. Re:  Question on syntax (Rustom Mody)


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

Message: 1
Date: Fri, 24 Oct 2014 16:30:36 +0300
From: Julius Gedvilas <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] GHCi error msgs
Message-ID:
        <CAOwifxKKESNPk9bZnKL525wuvJcX==8BJoFAr3Y=tqW74=j...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

How difficult would it be to change format of GHCi compile-time
error-messages of type "couldn't match expected type"?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20141024/e782184b/attachment-0001.html>

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

Message: 2
Date: Fri, 24 Oct 2014 16:56:35 +0100
From: Karolis Velicka <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] GHCi error msgs
Message-ID:
        <CANxL2L5R0xx5dguvWmx13Sx3dKHZN-9XwHE1ypOdjE3aVy=k...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

What do you mean by that? Can you give an example?

Best wishes,
Karl (Karolis) Velicka


On 24 October 2014 14:30, Julius Gedvilas <[email protected]> wrote:
> How difficult would it be to change format of GHCi compile-time
> error-messages of type "couldn't match expected type"?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>


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

Message: 3
Date: Fri, 24 Oct 2014 19:10:59 +0300
From: Julius Gedvilas <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] GHCi error msgs
Message-ID:
        <caowifxllx+ez45gxuxyrwdhaajlzsfgr0gq0hx4wbb+rqku...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

You load a *.hs file into ghci (cabal repl) and, if types does not add up,
you get an error message in form of "*.hs:line:col: Couldn't match expected
type <Type> with actual type <Type> ...".

I may like to reformat that message with Parsec.

On Fri, Oct 24, 2014 at 6:56 PM, Karolis Velicka <[email protected]>
wrote:

> What do you mean by that? Can you give an example?
>
> Best wishes,
> Karl (Karolis) Velicka
>
>
> On 24 October 2014 14:30, Julius Gedvilas <[email protected]> wrote:
> > How difficult would it be to change format of GHCi compile-time
> > error-messages of type "couldn't match expected type"?
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> _______________________________________________
> 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/20141024/dfb3738a/attachment-0001.html>

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

Message: 4
Date: Sat, 25 Oct 2014 11:31:01 +0800
From: Rohit Sharma <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Question on syntax
Message-ID:
        <cabghn3duje8vv_w2xad7jzfow8vdwnz_ebm4zzx8bbspqjs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

All,

I started learning haskell very recently and have a question on the pattern
matching style for lists.

In the below snippet i.e. "(x:xs)" why do we went with round braces and not
square? I know we are using cons that tells this is not a tuple but would
it not make more sense to write something like [x:xs] instead of (x:xs), i
thought round braces was used for pair/tuples?

safeHead [] = Nothing
safeHead (x:xs) = Just x

Thanks,
Rohit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20141025/00248e82/attachment-0001.html>

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

Message: 5
Date: Fri, 24 Oct 2014 20:41:11 -0700
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on syntax
Message-ID:
        <cacwmpm-o4jpojz-pdwekei_sqhfxrg0fwdtxzh+tauq-6_g...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Round braces are used for grouping, it's necessary to avoid ambiguity since
a function can be defined with more than one argument. When using case you
don't have this potential ambiguity, so don't need the parentheses. Tuples
are more of a special case in the grammar that isn't closely related to
this.

safeHead p = case p of
  [] -> Nothing
  x : xs -> Just x

On Friday, October 24, 2014, Rohit Sharma <[email protected]> wrote:

> All,
>
> I started learning haskell very recently and have a question on the
> pattern matching style for lists.
>
> In the below snippet i.e. "(x:xs)" why do we went with round braces and
> not square? I know we are using cons that tells this is not a tuple but
> would it not make more sense to write something like [x:xs] instead of
> (x:xs), i thought round braces was used for pair/tuples?
>
> safeHead [] = Nothing
> safeHead (x:xs) = Just x
>
> Thanks,
> Rohit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20141024/3a340d8a/attachment-0001.html>

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

Message: 6
Date: Sat, 25 Oct 2014 09:35:57 +0530
From: Rustom Mody <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on syntax
Message-ID:
        <caj+teodnxkvvavgtx7_6vusnoa51s_aqnu5ygzwhmqhwdbk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Oct 25, 2014 at 9:01 AM, Rohit Sharma <[email protected]> wrote:

> All,
>
> I started learning haskell very recently and have a question on the
> pattern matching style for lists.
>
> In the below snippet i.e. "(x:xs)" why do we went with round braces and
> not square? I know we are using cons that tells this is not a tuple but
> would it not make more sense to write something like [x:xs] instead of
> (x:xs), i thought round braces was used for pair/tuples?
>
> safeHead [] = Nothing
> safeHead (x:xs) = Just x
>
>
Yes this can be confusing.

Lets break it into two separate questions:
1. Why [] is not used around x:xs
2. Why () is used

To address 1 start ghci and try out these expressions

1: [2,3]

[1:[2,3]]


To address 2 try out

length [1,2] ++ [3,4]

and then

length ([1,2] ++ [3,4])

Another related example

sin pi/2

and
sin (pi/2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20141025/91725df3/attachment-0001.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 76, Issue 21
*****************************************

Reply via email to