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: Illegal datatype context when modelling round robin
scheduler (Brent Yorgey)
2. Re: Illegal datatype context when modelling round robin
scheduler (Jonathan Rioux)
3. Re: Install bullet-0.2.2 failure in OS X 10.8.2
(Trung Quang Nguyen)
4. (: (Ezequiel Hernan Di Giorgi)
5. Re: (: (Kim-Ee Yeoh)
----------------------------------------------------------------------
Message: 1
Date: Thu, 6 Dec 2012 10:07:11 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Illegal datatype context when
modelling round robin scheduler
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1
On Thu, Dec 06, 2012 at 09:47:31AM -0500, Jonathan Rioux wrote:
> On Thu, Dec 6, 2012 at 9:24 AM, Xiao Jia <[email protected]> wrote:
>
> > Hi, I'm trying to model a round robin scheduler in Haskell.
> >
> > > class Schedulable s where
> > > isFinal :: s -> Bool
> > >
> > > class Scheduler s where
> > > add :: (Schedulable a) => a -> s -> s
> > > next :: (Schedulable a) => s -> (a, s)
> > > empty :: s -> Bool
> > >
> > > data Schedulable a => RoundRobin = RoundRobin [a] [a]
> > >
> > > instance Scheduler RoundRobin where
> > > add p (RoundRobin ps qs) = RoundRobin (ps ++ [p]) qs
> > >
> > > next (RoundRobin [] qs) = next (RoundRobin qs [])
> > > next (RoundRobin (p:ps) qs) = (p, RoundRobin ps (qs ++ [p]))
> > >
> > > empty (RoundRobin [] _) = True
> > > empty _ = False
> >
> > However, GHC complains that
> >
> > > main.hs:9:6:
> > > Illegal datatype context (use -XDatatypeContexts): Schedulable a =>
> >
> > After some searches I realized that datatype contexts are deprecated.
> > So how can I model the scheduler without using datatype contexts?
> >
> > Thanks.
> >
> > --
> > Regards,
> > Xiao Jia
> >
> >
> Hello Xiao,
>
> From what I've read from this page (
> http://hackage.haskell.org/trac/haskell-prime/wiki/NoDatatypeContexts ),
> you simply need to remove ? Schedulable a ? from 9th line.
> It would there fore read like so :
>
>
> data Schedulable a => RoundRobin = RoundRobin [a] [a]
I think you meant
data RoundRobin a = RoundRobin [a] [a]
-Brent
------------------------------
Message: 2
Date: Thu, 6 Dec 2012 10:20:57 -0500
From: Jonathan Rioux <[email protected]>
Subject: Re: [Haskell-beginners] Illegal datatype context when
modelling round robin scheduler
To: Brent Yorgey <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<cah3n84wmaxg5wvv6c6fybnop7zjmyr4dpuqjraihx6w8doz...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Indeed. I replied too quickly...
On Thu, Dec 6, 2012 at 10:07 AM, Brent Yorgey <[email protected]>wrote:
> On Thu, Dec 06, 2012 at 09:47:31AM -0500, Jonathan Rioux wrote:
> > On Thu, Dec 6, 2012 at 9:24 AM, Xiao Jia <[email protected]> wrote:
> >
> > > Hi, I'm trying to model a round robin scheduler in Haskell.
> > >
> > > > class Schedulable s where
> > > > isFinal :: s -> Bool
> > > >
> > > > class Scheduler s where
> > > > add :: (Schedulable a) => a -> s -> s
> > > > next :: (Schedulable a) => s -> (a, s)
> > > > empty :: s -> Bool
> > > >
> > > > data Schedulable a => RoundRobin = RoundRobin [a] [a]
> > > >
> > > > instance Scheduler RoundRobin where
> > > > add p (RoundRobin ps qs) = RoundRobin (ps ++ [p]) qs
> > > >
> > > > next (RoundRobin [] qs) = next (RoundRobin qs [])
> > > > next (RoundRobin (p:ps) qs) = (p, RoundRobin ps (qs ++ [p]))
> > > >
> > > > empty (RoundRobin [] _) = True
> > > > empty _ = False
> > >
> > > However, GHC complains that
> > >
> > > > main.hs:9:6:
> > > > Illegal datatype context (use -XDatatypeContexts): Schedulable a
> =>
> > >
> > > After some searches I realized that datatype contexts are deprecated.
> > > So how can I model the scheduler without using datatype contexts?
> > >
> > > Thanks.
> > >
> > > --
> > > Regards,
> > > Xiao Jia
> > >
> > >
> > Hello Xiao,
> >
> > From what I've read from this page (
> > http://hackage.haskell.org/trac/haskell-prime/wiki/NoDatatypeContexts ),
> > you simply need to remove ? Schedulable a ? from 9th line.
> > It would there fore read like so :
> >
> >
> > data Schedulable a => RoundRobin = RoundRobin [a] [a]
>
> I think you meant
>
> data RoundRobin a = RoundRobin [a] [a]
>
> -Brent
>
> _______________________________________________
> 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/20121206/d6b6506f/attachment-0001.htm>
------------------------------
Message: 3
Date: Thu, 6 Dec 2012 21:16:10 +0100
From: Trung Quang Nguyen <[email protected]>
Subject: Re: [Haskell-beginners] Install bullet-0.2.2 failure in OS X
10.8.2
To: Daniel Fischer <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<cals5ubxrpms++ggax3vo1mfegeovbv4wd9ehr7azk866ztg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thanks a lot Daniel. I will try to find out. I have just installed Haskell
today, so I don't understand much about these error messages.
Best regards,
Trung
2012/12/6 Daniel Fischer <[email protected]>
> On Donnerstag, 6. Dezember 2012, 12:51:55, Trung Quang Nguyen wrote:
> > Hi there,
> >
> > After installing c2hs, and run cabal install bullet. I got this error.
> Did
> > I miss any step?
>
> No, the maintainer of bullet just has not updated the package to
> incorporate
> the changes in base-4.6.
> >
> > Physics/Bullet/Raw/C2HS.hs:211:12:
> > Could not deduce (Eq a) arising from a use of `toBool'
> > from the context (Num a)
> > bound by the type signature for cToBool :: Num a => a -> Bool
> > at Physics/Bullet/Raw/C2HS.hs:211:1-17
> > Possible fix:
> > add (Eq a) to the context of
> > the type signature for cToBool :: Num a => a -> Bool
> > In the expression: toBool
> > In an equation for `cToBool': cToBool = toBool
>
> Formerly, Eq and Show were superclasses of Num (
>
> class (Eq a, Show a) => Num a where...
>
> ) but they have been removed recently (they prevented some reasonable Num
> instances unless you mad dummy Eq and Show instances,
>
> instance Num a => Num (e -> a)
>
> for example).
>
> So before base-4.6, a Num constraint implied Eq, that is no longer so.
>
> Quick fix:
>
> $ cabal unpack bullet
> - cd bullet-0.2.2
> - edit the .cabal file, bumping the version to 0.2.2.1 or so
> - edit the sources adding Eq or Show constraints where necessary (you have
> seen one spot, cabal configure and after that cabal build would detect
> further
> spots if there are any, cabal install too, but if you configure with
> --disable-library-profiling --disable-shared, cabal build is quicker to
> find
> the spots)
> - cabal install
> (no arguments, so it configures and installs the package from the
> directory)
>
> Long-term fix: send a patch (or at least a bug report/feature request) to
> the
> maintainer of bullet.
>
--
*Trung Nguyen*
Mobile: +45 50 11 10 63
LinkedIn: http://www.linkedin.com/pub/trung-nguyen/36/a44/187
View my blog at http://www.onextrabit.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121206/12384c44/attachment-0001.htm>
------------------------------
Message: 4
Date: Thu, 6 Dec 2012 21:06:31 -0300
From: Ezequiel Hernan Di Giorgi <[email protected]>
Subject: [Haskell-beginners] (:
To: [email protected]
Message-ID:
<cahrx9syty-dspewp1d2y8nmd3sg3fnljybcgzzhlvpocpzw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
this code compiles correcly:
newtype State s a = State { runState :: *s* -> (a,s) }
instance Monad (State s) where
--return :: a -> State s a
return x = State (\st -> (*x,st*))
but this one doesn't compile:
newtype State s a = State { runState :: *a* -> (a,s) }
instance Monad (State s) where
--return :: a -> State s a
return x = State (\st -> (*st,x*))
Why is this happening?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121206/9208a7ae/attachment-0001.htm>
------------------------------
Message: 5
Date: Fri, 7 Dec 2012 09:17:20 +0700
From: Kim-Ee Yeoh <[email protected]>
Subject: Re: [Haskell-beginners] (:
To: Ezequiel Hernan Di Giorgi <[email protected]>
Cc: [email protected]
Message-ID:
<CAPY+ZdSf=5d8hjv862y-nev+o92qccv1wvo7rwtykg8dojc...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
So you flipped the elements of the pair in your definition of return from
(x,st) to (st,x).
But look at your newtype:s->(a,s) becomes a->(a,s). /Everything else/ stays
the same, including the order of your (State s a) parameters. Does that
help?
Another hint: what do you think the (type!) variables "a" and "s" stand for?
-- Kim-Ee
On Fri, Dec 7, 2012 at 7:06 AM, Ezequiel Hernan Di Giorgi <
[email protected]> wrote:
> this code compiles correcly:
>
> newtype State s a = State { runState :: *s* -> (a,s) }
>
> instance Monad (State s) where
> --return :: a -> State s a
> return x = State (\st -> (*x,st*))
>
> but this one doesn't compile:
>
> newtype State s a = State { runState :: *a* -> (a,s) }
>
> instance Monad (State s) where
> --return :: a -> State s a
> return x = State (\st -> (*st,x*))
>
> Why is this happening?
>
>
> _______________________________________________
> 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/20121207/b57449f3/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 54, Issue 10
*****************************************