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:  About monad (Trung Quang Nguyen)
   2. Re:  About monad (Miguel Negrao)
   3. Re:  About monad (Trung Quang Nguyen)
   4. Re:  Install bullet-0.2.2 failure in OS X 10.8.2
      (Trung Quang Nguyen)


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

Message: 1
Date: Thu, 20 Dec 2012 15:45:00 +0100
From: Trung Quang Nguyen <[email protected]>
Subject: Re: [Haskell-beginners] About monad
To: David McBride <[email protected]>, beginners
        <[email protected]>
Message-ID:
        <cals5ubz_i2oc1i2hkn+bjzf2+uz1ouq5ebrmylkxygmtw3q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi David,

Yours is more precise. f should output (ValueConstructor value) instead of
(Monad value) :)

--Trung




2012/12/20 David McBride <[email protected]>

> The way I like to reason about these things
> Prelude> :t (>>=)
>
> (>>=) :: Monad m => m a -> (a -> m b) -> m b
>
> Since the Monad m in this definition is Maybe, I'll just substitute it in
> like so:
> Maybe a -> (a -> Maybe b) -> Maybe b
>
> Then you notice that f is not (a -> b), it is (a -> Maybe b).
>
> On Thu, Dec 20, 2012 at 9:07 AM, Trung Quang Nguyen 
> <[email protected]>wrote:
>
>> Hi all,
>>
>> I saw this
>>
>>
>>    1. instance Monad Maybe where
>>    2.     return x = Just x
>>    3.     Nothing >>= f = Nothing
>>    4.     Just x >>= f  = f x
>>    5.     fail _ = Nothing
>>
>>
>> I am wondering about the implementation of function (>>=). Why don't it
>> be *Just x >>= f = Just (f x)*?
>>
>> Any body knows about this?
>>
>> --Trung
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>


-- 
*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/20121220/7dedd86a/attachment-0001.htm>

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

Message: 2
Date: Thu, 20 Dec 2012 15:25:10 +0000
From: Miguel Negrao <[email protected]>
Subject: Re: [Haskell-beginners] About monad
To: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252


A 20/12/2012, ?s 14:07, Trung Quang Nguyen escreveu:

> Hi all,
> 
> I saw this
> 
>       ? instance Monad Maybe where  
>       ?     return x = Just x  
>       ?     Nothing >>= f = Nothing  
>       ?     Just x >>= f  = f x  
>       ?     fail _ = Nothing  
> 
> I am wondering about the implementation of function (>>=). Why don't it be 
> Just x >>= f = Just (f x)?
> 
> Any body knows about this?

That would be the implementation of fmap for Maybe:

instance  Functor Maybe  where
    fmap _ Nothing       = Nothing
    fmap f (Just a)      = Just (f a)

so, different behavior.

best,
Miguel


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

Message: 3
Date: Thu, 20 Dec 2012 16:39:03 +0100
From: Trung Quang Nguyen <[email protected]>
Subject: Re: [Haskell-beginners] About monad
To: beginners <[email protected]>
Message-ID:
        <cals5ubxa-rpbq4e57mv+p6fophpyis42q2bq6_-fs3fatxd...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

*fmap*<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:fmap>
::
Functor f => (a -> b) -> f a -> f
b<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:fmap>
fmap f (Just a)      = Just (f a)

We wrap Just around (f a) because f return a value with type b instead
(Just b).

But in
(*>>=*)<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:-62--62--61->
::
Monad m => m a -> (a -> m b) -> m
b<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:-62--62--61->
Just x >>= f  = f x

We don't need to wrap Just around (f a) because f return (Just b).

--Trung



2012/12/20 Miguel Negrao <[email protected]>

>
> A 20/12/2012, ?s 14:07, Trung Quang Nguyen escreveu:
>
> > Hi all,
> >
> > I saw this
> >
> >       ? instance Monad Maybe where
> >       ?     return x = Just x
> >       ?     Nothing >>= f = Nothing
> >       ?     Just x >>= f  = f x
> >       ?     fail _ = Nothing
> >
> > I am wondering about the implementation of function (>>=). Why don't it
> be Just x >>= f = Just (f x)?
> >
> > Any body knows about this?
>
> That would be the implementation of fmap for Maybe:
>
> instance  Functor Maybe  where
>     fmap _ Nothing       = Nothing
>     fmap f (Just a)      = Just (f a)
>
> so, different behavior.
>
> best,
> Miguel
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
*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/20121220/e857be6c/attachment-0001.htm>

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

Message: 4
Date: Thu, 20 Dec 2012 20:20: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:
        <CALs5uBy_Er3kNOy=cQJZJEuONgPXhc67Ezu=6ludeyj2948...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I have just found a new version of haskell bullet on github
https://github.com/csabahruska/bullet

It includes example and it's a newer version 0.2.3 compared to the version
from cabal.

But then, when I tried to build the example, I got this. Any body has any
idea? Thanks a lot! (I'm using MacOsx 10.8.2)

~/w/r/s/h/b/example> ghc --make -O2 BulletExample
Linking BulletExample ...
Undefined symbols for architecture x86_64:
  "btUniversalConstraint::btUniversalConstraint(btRigidBody&, btRigidBody&,
btVector3&, btVector3&, btVector3&)", referenced from:
      _btUniversalConstraint_new in libHSbullet-0.2.3.a(Bullet.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

--Trung



2012/12/6 Trung Quang Nguyen <[email protected]>

> 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/
>
>
>


-- 
*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/20121220/24dc6769/attachment.htm>

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

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


End of Beginners Digest, Vol 54, Issue 31
*****************************************

Reply via email to