Send Beginners mailing list submissions to
[email protected]
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
[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. Problems with lifting code (PATRICK BROWNE)
2. Re: Problems with lifting code (Francesco Ariis)
3. Re: Problems with lifting code (Imants Cekusins)
4. Re: Problems with lifting code (PATRICK BROWNE)
5. Re: Problems with lifting code (PATRICK BROWNE)
----------------------------------------------------------------------
Message: 1
Date: Sun, 2 Oct 2016 15:54:07 +0100
From: PATRICK BROWNE <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Problems with lifting code
Message-ID:
<cagflrkd+_+thpvmbkt65q93ok_ytigwkaxe1sg3ycibyv3q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
I am trying, without sucess, to run the code below from [1] (Section 4.3).
Obviouly I am missing something.
I would like to keep as close to the original code as possible.
Any help would be apreciated.
Regards,
Pat
[1] http://publik.tuwien.ac.at/files/pub-geo_2321.pdf
data MyNumbers a = MyNum a deriving Show
class (Floating a) => Numbers a where
sqr :: a -> a
-- Not sure if i need these
-- instance Num (MyNumbers a) where
-- instance Fractional (MyNumbers a) where
class Lifts b a where
lift0 :: a -> b a
lift1 :: (a -> a) -> b a -> b a
instance Lifts MyNumbers a where
lift0 x = MyNum x
lift1 o x = MyNum (o x) -- ** Couldn't match expected type `a' with
actual type `MyNumbers a' **
instance (Floating (MyNumbers Float)) => Numbers (MyNumbers Float) where
sqr x = lift1 sqr x -- ** could not deduce (Numbers Float) arising from
a use of `sqr' **
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa
ríomhphost nó sna hiatáin seo. www.dit.ie
Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161002/b6a91873/attachment-0001.html>
------------------------------
Message: 2
Date: Sun, 2 Oct 2016 17:38:24 +0200
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Problems with lifting code
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sun, Oct 02, 2016 at 03:54:07PM +0100, PATRICK BROWNE wrote:
> Hi,
> I am trying, without sucess, to run the code below from [1] (Section 4.3).
> Obviouly I am missing something.
> I would like to keep as close to the original code as possible.
> Any help would be apreciated.
> Regards,
> Pat
> [1] http://publik.tuwien.ac.at/files/pub-geo_2321.pdf
>
I get different errors from yours (missing extension, Illegal
instance declaration). Can you paste the exact file you are
loading with ghci (because you are using ghci, right?)?
------------------------------
Message: 3
Date: Sun, 2 Oct 2016 17:57:54 +0200
From: Imants Cekusins <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Problems with lifting code
Message-ID:
<CAP1qinatCSeEbtKDjpZ9EnXW9R=m-utb9bgznx0p3+9mhos...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
this works:
{-# LANGUAGE MultiParamTypeClasses,FlexibleInstances #-}
module Lift where
newtype MyNumbers a = MyNum a deriving Show
class Numbers a where
sqr :: a -> a
class Lifts b a where
lift0 :: a -> b a
lift1 :: (a -> a) -> b a -> b a
instance Lifts MyNumbers a where
lift0 x = MyNum x
lift1 o (MyNum x) = MyNum (o x)
instance Numbers Float where
sqr x = x * x
instance Numbers (MyNumbers Float) where
sqr x = lift1 sqr x
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161002/3b4fe4f7/attachment-0001.html>
------------------------------
Message: 4
Date: Sun, 2 Oct 2016 17:03:25 +0100
From: PATRICK BROWNE <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Problems with lifting code
Message-ID:
<CAGFLrKd=kpajxsw7xkfakrzpqjzh3qnvotm7zzx9dvxtdoq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Yes, I am running ghci 8.0.1.
Below, I have added the language pragmas suggested by the compiler
Regards,
Pat
.
{-# LANGUAGE
MultiParamTypeClasses,FlexibleInstances,FlexibleContexts,UndecidableInstances
#-}
data MyNumbers a = MyNum a deriving Show
class (Floating a) => Numbers a where
sqr :: a -> a
class Lifts b a where
lift0 :: a -> b a
lift1 :: (a -> a) -> b a -> b a
instance Lifts MyNumbers a where
lift0 x = MyNum x
lift1 o x = MyNum (o x)
instance (Floating (MyNumbers Float)) => Numbers (MyNumbers Float) where
sqr x = lift1 sqr x
On 2 October 2016 at 16:38, Francesco Ariis <[email protected]> wrote:
> On Sun, Oct 02, 2016 at 03:54:07PM +0100, PATRICK BROWNE wrote:
> > Hi,
> > I am trying, without sucess, to run the code below from [1] (Section
> 4.3).
> > Obviouly I am missing something.
> > I would like to keep as close to the original code as possible.
> > Any help would be apreciated.
> > Regards,
> > Pat
> > [1] http://publik.tuwien.ac.at/files/pub-geo_2321.pdf
> >
>
> I get different errors from yours (missing extension, Illegal
> instance declaration). Can you paste the exact file you are
> loading with ghci (because you are using ghci, right?)?
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa
ríomhphost nó sna hiatáin seo. www.dit.ie
Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161002/3d12b68a/attachment-0001.html>
------------------------------
Message: 5
Date: Sun, 2 Oct 2016 17:15:57 +0100
From: PATRICK BROWNE <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Problems with lifting code
Message-ID:
<CAGFLrKdZ8C=k+frtbcrc6wupwag0hhcee9xlam9xu7v05wo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
So it seems that
(1) lift1 o x = MyNum (o x)
Needed to be rewritten to
(2) lift1 o (MyNum x) = MyNum (o x)
I am not sure why the constructor is used on the LHS of (2)
Thanks for all your help.
Pat
On 2 October 2016 at 17:03, PATRICK BROWNE <[email protected]> wrote:
> Yes, I am running ghci 8.0.1.
> Below, I have added the language pragmas suggested by the compiler
> Regards,
> Pat
> .
> {-# LANGUAGE
> MultiParamTypeClasses,FlexibleInstances,FlexibleContexts,UndecidableInstances
> #-}
>
> data MyNumbers a = MyNum a deriving Show
>
> class (Floating a) => Numbers a where
> sqr :: a -> a
>
>
> class Lifts b a where
> lift0 :: a -> b a
> lift1 :: (a -> a) -> b a -> b a
>
> instance Lifts MyNumbers a where
> lift0 x = MyNum x
> lift1 o x = MyNum (o x)
>
> instance (Floating (MyNumbers Float)) => Numbers (MyNumbers Float) where
> sqr x = lift1 sqr x
>
> On 2 October 2016 at 16:38, Francesco Ariis <[email protected]> wrote:
>
>> On Sun, Oct 02, 2016 at 03:54:07PM +0100, PATRICK BROWNE wrote:
>> > Hi,
>> > I am trying, without sucess, to run the code below from [1] (Section
>> 4.3).
>> > Obviouly I am missing something.
>> > I would like to keep as close to the original code as possible.
>> > Any help would be apreciated.
>> > Regards,
>> > Pat
>> > [1] http://publik.tuwien.ac.at/files/pub-geo_2321.pdf
>> >
>>
>> I get different errors from yours (missing extension, Illegal
>> instance declaration). Can you paste the exact file you are
>> loading with ghci (because you are using ghci, right?)?
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa
ríomhphost nó sna hiatáin seo. www.dit.ie
Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161002/d2e1f34b/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 100, Issue 3
*****************************************