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: Can I force cabal to install a package always to be
installed with --enable-library-profiling (Krzysztof Skrz?tnicki)
2. Re: Can I force cabal to install a package always to be
installed with --enable-library-profiling (Brent Yorgey)
3. Re: RandT (aditya siram)
4. Re: RandT (aditya siram)
5. How to "insert" a cross reference into a tree structure
(Tim Baumgartner)
6. Re: How to "insert" a cross reference into a tree structure
(Tim Baumgartner)
7. Re: How to "insert" a cross reference into a tree structure
(Edward Z. Yang)
----------------------------------------------------------------------
Message: 1
Date: Sun, 19 Dec 2010 00:53:44 +0100
From: Krzysztof Skrz?tnicki <[email protected]>
Subject: Re: [Haskell-beginners] Can I force cabal to install a
package always to be installed with --enable-library-profiling
To: Daniel Seidel <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
cabal-install has it's configuration file. On Linux and alike it's located
in HOME/.cabal/config. You can set "library-profiling: True" there. There
are also a bunch of other options you might be interested in.
Best regards,
Krzysztof Skrz?tnicki
On Fri, Dec 17, 2010 at 16:41, Daniel Seidel <[email protected]> wrote:
> Hi,
>
> I want to create a cabal package and want to enforce via the
> descriptions in the .cabal file that it is always installed with
> --enable-library-profiling. Unfortunately I couldn't figure this out
> from the cabal documentation. I found how I can enforce that my cabal
> always installs profiling versions, but not if and how I can enforce
> that one special package is installed that way by any cabal
> installation. Is this possible, and if how?
>
> Cheers, Daniel.
>
>
> _______________________________________________
> 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/20101219/73bfc5e7/attachment-0001.htm>
------------------------------
Message: 2
Date: Sat, 18 Dec 2010 21:23:14 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Can I force cabal to install a
package always to be installed with --enable-library-profiling
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Fri, Dec 17, 2010 at 04:41:31PM +0100, Daniel Seidel wrote:
> Hi,
>
> I want to create a cabal package and want to enforce via the
> descriptions in the .cabal file that it is always installed with
> --enable-library-profiling. Unfortunately I couldn't figure this out
> from the cabal documentation. I found how I can enforce that my cabal
> always installs profiling versions, but not if and how I can enforce
> that one special package is installed that way by any cabal
> installation. Is this possible, and if how?
I do not think it is possible, although I am not 100% sure.
-Brent
------------------------------
Message: 3
Date: Sat, 18 Dec 2010 23:30:42 -0600
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] RandT
To: Amy de Buitl?ir <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
In the code below the "RandT ..." monad transformer is replaced by a
simple "State ..." monad. And the Animal is now a type family with the
brain being one of it's instances. This way functions that work on
specific parts of the animal will have "Animal Brain" in the signature
and ones that work with all parts of the animal will have "Animal a".
-deech
{-# LANGUAGE PackageImports, RankNTypes, FlexibleContexts,
TypeFamilies, EmptyDataDecls #-}
import "mtl" Control.Monad.State
import Control.Monad.Random
type Neuron = Int
data Brain
type family Animal a
type instance Animal Brain = [Neuron]
stimulateBrain :: (RandomGen g) => Int -> [Double] -> State (Animal Brain,g) ()
stimulateBrain n xs = do
(a,g) <- get
g' <- return $ next g
a' <- return $ stimulate n xs g' a
put (a',g')
where
next :: (RandomGen g) => g -> g
next = snd . split
stimulate :: (RandomGen g) => Int -> [Double] -> g -> Animal Brain ->
Animal Brain
stimulate n xs g neurons = undefined
On Fri, Dec 17, 2010 at 10:11 PM, Amy de Buitl?ir <[email protected]> wrote:
> The example below shows part of the architecture I'm using for an alife
> project.
>
> Q1: My implementation of "simulateBrain" seems clumsy. Is there a
> better way to do this?
>
> Q2: The "Animal" type includes a "brain" component. I implemented that
> as a simple list, but perhaps it would be better to use a monad here?
> I tried doing that, but I couldn't figure out the syntax. The closest
> I got was when I defined a "type Brain g a = (RandomGen g) => RandT g
> (State [Neuron]) a". But that a specifies a result type, which doesn't
> make sense to me for a record component.
>
> Thank you,
> Amy
>
> ----- SAMPLE CODE -----
>
> {-# LANGUAGE PackageImports, RankNTypes, FlexibleContexts #-}
>
> import "mtl" Control.Monad.State
> import Control.Monad.Random
>
> type Neuron = Int -- The real type is more complex
>
> -- An "Alife" animal
> data Animal = Animal
> ?{
> ? ? brain :: [Neuron]
> ? ? -- There are other fields too, of course
> ?} deriving (Show, Read)
>
> -- | Stimulates an animal's brain, and allows it to react.
> stimulateBrain :: (RandomGen g)
> ?-- | The number of cycles
> ?=> Int
> ?-- | The signals to apply to the sensor neurons
> ?-> [Double]
> ?-- | The animal
> ?-> RandT g (State Animal) ()
> stimulateBrain n xs = do
> ?c <- get
> ?g <- getSplit
> ?let b' = execState (evalRandT (stimulate n xs) g) (brain c)
> ?put $ c{brain=b'}
>
>
> -- | Feeds some input signals into a brain, and allow it to react.
> stimulate :: (RandomGen g)
> ?-- | The number of cycles
> ?=> Int
> ?-- | The signals to apply to the sensor neurons
> ?-> [Double]
> ?-- | The neuron states
> ?-> RandT g (State [Neuron]) ()
> stimulate k xs = return () -- The real implementation is more complex
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 4
Date: Sat, 18 Dec 2010 23:40:58 -0600
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] RandT
To: Amy de Buitl?ir <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Actually "stimulateBrain" could be refactored to :
stimulateBrain :: (RandomGen g) => Int -> [Double] -> State (Animal Brain,g) ()
stimulateBrain n xs = do
modify (\(a,g) -> (stimulate n xs g a , next g))
where
next :: (RandomGen g) => g -> g
next = snd . split
-deech
On Sat, Dec 18, 2010 at 11:30 PM, aditya siram <[email protected]> wrote:
> In the code below the "RandT ..." monad transformer is replaced by a
> simple "State ..." monad. And the Animal is now a type family with the
> brain being one of it's instances. This way functions that work on
> specific parts of the animal will have "Animal Brain" in the signature
> and ones that work with all parts of the animal will have "Animal a".
>
> -deech
>
> ?{-# LANGUAGE PackageImports, RankNTypes, FlexibleContexts,
> TypeFamilies, EmptyDataDecls #-}
> import "mtl" Control.Monad.State
> import Control.Monad.Random
>
> type Neuron = Int
> data Brain
>
> type family Animal a
> type instance Animal Brain = [Neuron]
>
> stimulateBrain :: (RandomGen g) => Int -> [Double] -> State (Animal Brain,g)
> ()
> stimulateBrain n xs = do
> ?(a,g) <- get
> ?g' <- return $ next g
> ?a' <- return $ stimulate n xs g' a
> ?put (a',g')
> ?where
> ? ?next :: (RandomGen g) => g -> g
> ? ?next = snd . split
>
>
> stimulate :: (RandomGen g) => Int -> [Double] -> g -> Animal Brain ->
> Animal Brain
> stimulate n xs g neurons = undefined
>
>
>
>
> On Fri, Dec 17, 2010 at 10:11 PM, Amy de Buitl?ir <[email protected]> wrote:
>> The example below shows part of the architecture I'm using for an alife
>> project.
>>
>> Q1: My implementation of "simulateBrain" seems clumsy. Is there a
>> better way to do this?
>>
>> Q2: The "Animal" type includes a "brain" component. I implemented that
>> as a simple list, but perhaps it would be better to use a monad here?
>> I tried doing that, but I couldn't figure out the syntax. The closest
>> I got was when I defined a "type Brain g a = (RandomGen g) => RandT g
>> (State [Neuron]) a". But that a specifies a result type, which doesn't
>> make sense to me for a record component.
>>
>> Thank you,
>> Amy
>>
>> ----- SAMPLE CODE -----
>>
>> {-# LANGUAGE PackageImports, RankNTypes, FlexibleContexts #-}
>>
>> import "mtl" Control.Monad.State
>> import Control.Monad.Random
>>
>> type Neuron = Int -- The real type is more complex
>>
>> -- An "Alife" animal
>> data Animal = Animal
>> ?{
>> ? ? brain :: [Neuron]
>> ? ? -- There are other fields too, of course
>> ?} deriving (Show, Read)
>>
>> -- | Stimulates an animal's brain, and allows it to react.
>> stimulateBrain :: (RandomGen g)
>> ?-- | The number of cycles
>> ?=> Int
>> ?-- | The signals to apply to the sensor neurons
>> ?-> [Double]
>> ?-- | The animal
>> ?-> RandT g (State Animal) ()
>> stimulateBrain n xs = do
>> ?c <- get
>> ?g <- getSplit
>> ?let b' = execState (evalRandT (stimulate n xs) g) (brain c)
>> ?put $ c{brain=b'}
>>
>>
>> -- | Feeds some input signals into a brain, and allow it to react.
>> stimulate :: (RandomGen g)
>> ?-- | The number of cycles
>> ?=> Int
>> ?-- | The signals to apply to the sensor neurons
>> ?-> [Double]
>> ?-- | The neuron states
>> ?-> RandT g (State [Neuron]) ()
>> stimulate k xs = return () -- The real implementation is more complex
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
------------------------------
Message: 5
Date: Sun, 19 Dec 2010 09:42:43 +0100
From: Tim Baumgartner <[email protected]>
Subject: [Haskell-beginners] How to "insert" a cross reference into a
tree structure
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi Haskellers,
since I learned the basics of algebraic data types, I have a question.
First I thought I could answer it after getting a little more used to
Haskell's type system. But now I prefer to ask here. Given the
following example code, how can I "insert" a cross reference from the
track "Money for Nothing" to the artist "Sting" who sang the
background vocals? I know it must be a new MusicCollection, but I'd
like to know the shortest general code to construct it.
data MusicCollection = MusicCollection [Artist] deriving (Show)
data Artist = Artist String [Album] deriving (Show)
data Album? = Album? String [Track] deriving (Show)
data Track? = Track? String [Artist]
-- featured Artists are cross referenced, so Show cannot be derived
collection? = MusicCollection [direStraits, sting]
direStraits = Artist "Dire Straits" [brothersInArms]
brothersInArms? = Album "Brothers in Arms" [moneyForNothing]
moneyForNothing = Track "Money for Nothing" []
Thanks in advance
Tim
------------------------------
Message: 6
Date: Sun, 19 Dec 2010 09:55:57 +0100
From: Tim Baumgartner <[email protected]>
Subject: Re: [Haskell-beginners] How to "insert" a cross reference
into a tree structure
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I missed the definition of sting:
sting = Artist "Sting" []
------------------------------
Message: 7
Date: Sun, 19 Dec 2010 04:54:19 -0500
From: "Edward Z. Yang" <[email protected]>
Subject: Re: [Haskell-beginners] How to "insert" a cross reference
into a tree structure
To: Tim Baumgartner <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <1292752244-sup-4...@ezyang>
Content-Type: text/plain; charset=UTF-8
You can do this, but with some caveats; the technique is called tying the knot
[1]. However, if you decide to go subsequently change an Artist, any recursive
references to it must be updated too, and you will get very slow update.
> collection? = MusicCollection [direStraits, sting]
> direStraits = Artist "Dire Straits" [brothersInArms]
> brothersInArms? = Album "Brothers in Arms" [moneyForNothing]
> moneyForNothing = Track "Money for Nothing" [direStraits]
Is fine, laziness stops the infinite loop.
Related to editing values embedded deep in structures, but not related
to cross-references, you might find this post interesting:
http://conal.net/blog/posts/semantic-editor-combinators/
Cheers,
Edward
[1] http://www.haskell.org/haskellwiki/Tying_the_Knot
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 37
*****************************************