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. Re: basic Functor, Applicative and Monad instances
([email protected])
2. Re: basic Functor, Applicative and Monad instances
([email protected])
3. Cabal dependencies are per target or global?
(Dimitri DeFigueiredo)
4. Re: Cabal dependencies are per target or global?
(Dimitri DeFigueiredo)
5. Re: Cabal dependencies are per target or global? (Karl Voelker)
----------------------------------------------------------------------
Message: 1
Date: Fri, 17 Jul 2015 12:00:49 -0400
From: [email protected]
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] basic Functor, Applicative and Monad
instances
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
You have the types of the functions commented out in the instances. If you use
{-# LANGUAGE InstanceSigs #-} you can write them for real (and be sure that
they're accurate)
Tom
El Jul 17, 2015, a las 3:53, Imants Cekusins <[email protected]> escribi?:
> based on this snippet and Rein's comment, here is monad file template
> for intellij Idea to make new monads a quick exercise:
>
> module ${PACKAGE_NAME}.${NAME} where
>
>
> data ${Type} a = ${ctor} {
> ${prop}::a
> }
>
>
> instance Functor ${Type} where
> -- (a -> b) -> f a -> f b
> -- fmap f (${ctor} x) = ${ctor} (f x)
> fmap ab fa = let a1 = ${prop} fa
> b1 = ab a1
> in fa { ${prop} = b1 }
>
>
> instance Applicative ${Type} where
> -- a -> f a
> -- pure = ${ctor}
> pure a = ${ctor} { ${prop} = a }
>
> -- f (a -> b) -> f a -> f b
> -- ${ctor} f <*> ${ctor} x = ${ctor} (f x)
> (<*>) fab fa = let ab1 = ${prop} fab
> a1 = ${prop} fa
> b1 = ab1 a1
> in fa { ${prop} = b1 }
>
>
> instance Monad ${Type} where
> -- a -> m a
> return a = ${ctor} { ${prop} = a }
>
> -- m a -> (a -> m b) -> m b
> (>>=) ma amb = let a1 = ${prop} ma
> in amb a1
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
Message: 2
Date: Fri, 17 Jul 2015 14:06:09 -0400
From: [email protected]
To: Imants Cekusins <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] basic Functor, Applicative and Monad
instances
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Right, you'll want to say eg
fmap :: (a -> b) -> Val a -> Val b
Tom
El Jul 17, 2015, a las 12:23, Imants Cekusins <[email protected]> escribi?:
>> InstanceSigs
>
> Thank you Tom.
>
> this sig does not work though:
> fmap ::(a -> b) -> f a -> f b
------------------------------
Message: 3
Date: Fri, 17 Jul 2015 13:59:16 -0600
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Cabal dependencies are per target or
global?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
Hello,
I'm trying to figure out how cabal understands dependencies.
It seems all "build-depends:" sections have to build satisfied for any one
target to be built. Is that correct or is there a problem with my setup?
I assumed those "build-depends:" sections were "per target",
but apparently that not exactly the case.
I have a small .cabal file that builds the second target "myPersonalMain"
if and only if I comment out the build-dependencies for the first target
(i.e. myAgent)
here's my test file agent.cabal:
------------------------------------------------
name: agent
version: 0.1.0.0
synopsis: Just testing
author: Dimitri DeFigueiredo
maintainer: [email protected]
build-type: Simple
cabal-version: >=1.20
----------------------------------------------
executable myAgent
main-is: Main.hs
hs-source-dirs: ./src
build-depends: base >=4.6 && <4.7
, unordered-containers >= 0.2.3.0
, unix >= 2.6.0.1
, process >= 1.1.0.2
, stm >= 2.4.2
default-language: Haskell2010
----------------------------------------------
executable myPersonalMain
main-is: Mpm.hs
hs-source-dirs: ./src
build-depends:
base >=4.6
default-language: Haskell2010
----------------------------------------------
if I try to build the second target I get:
cabal build MyPersonalMain
./agent.cabal has been changed. Re-configuring with most recently used
options. If this fails, please run configure manually.
Resolving dependencies...
Configuring agent-0.1.0.0...
cabal: At least the following dependencies are missing:
process >=1.1.0.2,
stm >=2.4.2,
unix >=2.6.0.1,
unordered-containers >=0.2.3.0
could someone shed some light into this behavior?
Thanks,
Dimitri
------------------------------
Message: 4
Date: Fri, 17 Jul 2015 17:08:13 -0600
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Cabal dependencies are per target or
global?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
I guess my example was incomplete. I can make GHC run. Here's a modified
version where I do have the ghc-options line. I can build an executable
for the second target (myPersonalMain) by commenting
the "build-depends: section" for the first target (agent).
My .cabal file with (commented lines) is:
------------------------------------------------
name: agent
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.20
------------------------------------------------
executable agent
main-is: Main.hs
hs-source-dirs: ./src
-- build-depends: base >=4.6 && <4.7
-- , unordered-containers >= 0.2.3.0
-- , unix >= 2.6.0.1
-- , process >= 1.1.0.2
-- , stm >= 2.4.2
-- Base language which the package is written in.
default-language: Haskell2010
----------------------------------------------
executable myPersonalMain
main-is: Mpm.hs
hs-source-dirs: ./src
ghc-options: -main-is Mpm
build-depends:
base >=4.4
default-language: Haskell2010
----------------------------------------------
The contents of Mpm.hs are:
module Mpm where
main = putStrLn "Hi!"
But if I remove the comments in the .cabal file above, I get this:
Dis-machine:cabal-tests dimitri$ cabal build myPersonalMain
./agent.cabal has been changed. Re-configuring with most recently used
options. If this fails, please run configure manually.
Resolving dependencies...
Configuring agent-0.1.0.0...
cabal: At least the following dependencies are missing:
process >=1.1.0.2,
stm >=2.4.2,
unix >=2.6.0.1,
unordered-containers >=0.2.3.0
Is this a bug? Or am I missing something?
Cheers,
Dimitri
On 17/07/15 15:10, Imants Cekusins wrote:
> this could shed some light:
>
> http://stackoverflow.com/questions/14238729/producing-multiple-executables-from-single-project
>
> answer #2 was marked as answered
>
> ghc-options: -O2 -threaded -with-rtsopts=-N -main-is FirstExecutable
------------------------------
Message: 5
Date: Fri, 17 Jul 2015 18:29:23 -0700
From: Karl Voelker <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Cabal dependencies are per target or
global?
Message-ID:
<[email protected]>
Content-Type: text/plain
On Fri, Jul 17, 2015, at 04:08 PM, Dimitri DeFigueiredo wrote:
> Is this a bug? Or am I missing something?
The dependencies are not global. You can see this by trying to import a
module in Mpm.hs that is in one of the unique dependencies of "agent" -
the import fails. [1]
However, in order to build, you must first configure. And the
"configure" step cannot be done for a single executable - it's done for
the whole package. Since package dependencies are checked during the
configure step, you have to have all the dependencies in place for all
targets.
I think this is probably a good thing, because otherwise, you could end
up installing some packages that satisfy the dependencies of one target,
only to find out that the particular package versions which were chosen
make it impossible to satisfy the dependencies of the other target.
-Karl
1. https://gist.github.com/ktvoelker/d561889ac4bd56cadc2d
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 85, Issue 11
*****************************************