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:  invalid type signature last2::: [a] -> a (Roelof Wobben)
   2. Re:  invalid type signature last2::: [a] -> a (Henk-Jan van Tuyl)
   3. Re:  First Project: Imperative Algorithm Visualization tool
      (Daniel Trstenjak)
   4.  Are these soloutions all valid and a good use    of Haskell
      (Roelof Wobben)
   5. Re:  Are these soloutions all valid and a good use of Haskell
      (Karl Voelker)
   6. Re:  Are these soloutions all valid and a good use of Haskell
      (Chris Linton-Ford)


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

Message: 1
Date: Sun, 09 Nov 2014 20:09:11 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] invalid type signature last2::: [a]
        -> a
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20141109/f63adf31/attachment-0001.html>

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

Message: 2
Date: Sun, 09 Nov 2014 21:52:17 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <[email protected]>,
        "Roelof Wobben" <[email protected]>
Subject: Re: [Haskell-beginners] invalid type signature last2::: [a]
        -> a
Message-ID: <op.xo2r9jv5pz0j5l@alquantor>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes


You must add something like
   module X where
at the top of your file, to indicate that this is not the main module  
(where you must specify a main function).

Groeten,
Henk-Jan van Tuyl


On Sun, 09 Nov 2014 14:11:12 +0100, Roelof Wobben <[email protected]> wrote:

> Thanks,
>
> Now when I run it, I see a error message that main is missing.
> and I cannot find in theIlearnyouahaskell how to solve this.
>
> Roelof
>
>
>
>
> May Khaw schreef op 9-11-2014 11:17:
>
> The first one means that you gave a type signature for a function you  
> did not
> define.
>
> The second one means that there are 2 last2 type signature, but you can  
> only
> have one.
>
> What you want is something like :
> last2 :: [a] - > a
> last2 list = (put your function here)
>
> On Sun, 9 Nov 2014 21:02 Roelof Wobben <[email protected]> wrote:
>
> Thanks,
>
> I changed it to this :
>
> last2::[a]-> a
> last2::last[a]
>
> but now I see these error messages:
>
> src/Main.hs@1:1-1:6 The type signature forlast2 lacks an accompanying  
> binding
>
> src/Main.hs@2:1-2:6 Duplicate type signatures for last2
> at  
> /home/app/isolation-runner-work/projects/75679/session.207/src/src/Main.hs:1:1-5
> /home/app/isolation-runner-work/projects/75679/session.207/src/src/Main.hs:2:1-5
> src/Main.hs@2:1-2:6
>
> The type signature for last2 lacks an accompanying binding
>
>
> akash g schreef op 9-11-2014 10:48:
>
> The naming convention for variables and functions is that they should  
> start with
> a lower case letter. Types have capitalized names.
>
>
> On Sun, Nov 9, 2014 at 3:12 PM, Roelof Wobben <[email protected]> wrote:
> Hello,
>
> I try to solve the 99 haskell problems on several ways.
>
> But my first try which looks like this :
>
> Last2::[a]-> a
> Last2:: last[list]
>
> gives the following error message :
>
> src/Main.hs@1:1-1:6
> Invalid type signature: Last2 :: [a] -> a Should be of form <variable>
> :: <type>
>
> What am trying to do is say the input is a list which can be of integers
> or chars so everything is the output can then also be of type everything.


-- 
Folding@home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--


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

Message: 3
Date: Mon, 10 Nov 2014 10:26:38 +0100
From: Daniel Trstenjak <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] First Project: Imperative Algorithm
        Visualization tool
Message-ID: <20141110092638.GA4809@machine>
Content-Type: text/plain; charset=us-ascii


Hi Adit,

On Sun, Nov 09, 2014 at 11:19:48PM +0530, Adit Biswas wrote:
> So my higher level idea on approaching this problem is:
> 1. Create a dsl for describing data structures, e.g Link lists,
>    trees, graphs
> 2. Create a dsl for describing each step of the algorithms
>    manipulating the data structures
> 3. The algorithms would be a monadic composition of the step ADTs
> 4. Lift the algorithm to some monad which carries out the side
>    effects of making changes to a visualization.

I would start with defining the data structures which represent
your algorithm and then defining a function that renders your data.

If you're using OpenGL ist could be as simple as:

   render :: YourData -> IO ()


If you've a working version of this, then you could try defining
a DSL, and if you want a monadic one, then most likely you will
be using a free monad[1,2], so you don't have to write your own one.

But at the end runnning your DSL will just result into 'YourData'
and you can reuse your 'render' function.

You don't need any kind of special Monad for the rendering and
I also don't see any kind of advantage having one.


Greetings,
Daniel

[1] 
http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html
[2] https://hackage.haskell.org/package/free


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

Message: 4
Date: Mon, 10 Nov 2014 10:50:23 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Are these soloutions all valid and a good
        use     of Haskell
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,

I tried to solve the first problem of the 99 haskell problems on 3 
seperate ways.
The problem is that  I have to find the last item of a list.

The solutions I found with a little help of this mailinglist are :

last2::[a]-> Maybe a;
last2 [] = Nothing;
last2 ([x]) = Just x;
last2 (_:xs) = last2 xs

last3::[a]-> Maybe a;
last3 x
   | null x = Nothing
   | null xs = Just (head x)
   | otherwise = last3 (tail x)
   where xs = tail x

last4::[a]-> Maybe a;
last4 x = case x of
     [] -> Nothing ;
     [x] -> Just x ;
     (_:xs) -> last4 xs

main = print $ (last2 [] )

What do you experts think of the different ways ?

Roelof



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

Message: 5
Date: Mon, 10 Nov 2014 02:16:37 -0800
From: Karl Voelker <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Are these soloutions all valid and a
        good use of Haskell
Message-ID:
        <[email protected]>
Content-Type: text/plain

On Mon, Nov 10, 2014, at 01:50 AM, Roelof Wobben wrote:
> What do you experts think of the different ways ?

2 and 4 are quite similar, and both fine. 3 is not so good: guards
provide weaker guarantees than patterns, and head and tail are partial
functions.

All three implementations have in common that they do their own
recursion. It would be a good exercise to try implementing last as a
fold - in other words, letting the standard library do the recursion for
you.

-Karl


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

Message: 6
Date: Mon, 10 Nov 2014 10:24:57 +0000
From: Chris Linton-Ford <[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <[email protected]>
Subject: Re: [Haskell-beginners] Are these soloutions all valid and a
        good use of Haskell
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

I've seen this mentioned a couple of times - that you should avoid explicit 
recursion where possible in Haskell (although I can't find the references now).

Is this to make programs easier to understand, or more compact, or is there a 
performance benefit?

Chris



-----Original Message-----
From: Beginners [mailto:[email protected]] On Behalf Of Karl Voelker
Sent: Monday, November 10, 2014 10:17 AM
To: [email protected]
Subject: Re: [Haskell-beginners] Are these soloutions all valid and a good use 
of Haskell

On Mon, Nov 10, 2014, at 01:50 AM, Roelof Wobben wrote:
> What do you experts think of the different ways ?

2 and 4 are quite similar, and both fine. 3 is not so good: guards provide 
weaker guarantees than patterns, and head and tail are partial functions.

All three implementations have in common that they do their own recursion. It 
would be a good exercise to try implementing last as a fold - in other words, 
letting the standard library do the recursion for you.

-Karl
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
KCG Europe Limited is authorized and regulated by the Financial Conduct 
Authority. Registered Office 55 Basinghall Street, London, EC2V 5DU. Registered 
in England & Wales No. 03632121

This e-mail and its attachments are intended only for the individual or entity 
to whom it is addressed and may contain information that is confidential, 
privileged, inside information, or subject to other restrictions on use or 
disclosure. Any unauthorized use, dissemination or copying of this transmission 
or the information in it is prohibited and may be unlawful. If you have 
received this transmission in error, please notify the sender immediately by 
return e-mail, and permanently delete or destroy this e-mail, any attachments, 
and all copies (digital or paper). Unless expressly stated in this e-mail, 
nothing in this message should be construed as a digital or electronic 
signature. For additional important disclaimers and disclosures regarding KCG?s 
products and services, please click on the following link:

http://www.kcg.com/legal/global-disclosures

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 77, Issue 4
****************************************

Reply via email to