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't make distribution, requires rerunning ./configure
(Josh Stratton)
2. Re: lazy mapM (Ovidiu D)
----------------------------------------------------------------------
Message: 1
Date: Tue, 2 Apr 2013 09:16:09 -0700
From: Josh Stratton <[email protected]>
Subject: Re: [Haskell-beginners] can't make distribution, requires
rerunning ./configure
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<CAPVmgLg8FfPhxHi7VZD=9zxgb06d7nxc2rroewyn_r5os5v...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Downloading the platform, it says it needs to have ghc already installed.
Am I really the only one hitting this issue?
It's erroring out here...
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
include mk/config.mk
ifeq "$(ProjectVersion)" ""
$(error Please run ./configure first)
endif
endif
But I don't where this ProjectVersion is being set...
> grep ProjectVersion *
ghc.mk:ifeq "$(ProjectVersion)" ""
ghc.mk:SRC_DIST_BASE_NAME = ghc-$(ProjectVersion)
ghc.mk:SRC_DIST_GHC_NAME = ghc-$(ProjectVersion)-src
ghc.mk:SRC_DIST_TESTSUITE_NAME = ghc-$(ProjectVersion)-testsuite
ghc.mk: echo $(ProjectVersion) >VERSION
ghc.mk: tar tjf $(SRC_DIST_GHC_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||"
| sort >sdist-manifest
ghc.mk:SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
Makefile:ifeq "$(ProjectVersion)" ""
On Fri, Mar 29, 2013 at 5:38 AM, Hollister Herhold <[email protected]>wrote:
>
> (Coming from a Haskell newbie who has both used the Haskell Platform and
> built ghc from scratch-)
>
> You want the Haskell Platform. It comes with a bunch of useful libraries
> in addition to ghc. If you're a beginner, it will do everything you need
> for quite a while.
>
> Once you get used to using ghc and cabal and such, you can "upgrade" to
> the latest ghc (or the development head, if you're a bleeding-edge kind of
> person).
>
>
>
> On Mar 29, 2013, at 7:31 AM, Josh Stratton wrote:
>
> Maybe I'm confused, but I did download the binary package. That's the one
> I can't install. I downloaded the binary package and followed the steps in
> the INSTALL file which included running the configure step (with an
> optional prefix) and "make install". I don't think it's actually building
> ghc. I can try the haskell platform to see what happens.
>
>
> On Fri, Mar 29, 2013 at 12:05 AM, Karl Voelker <[email protected]>wrote:
>
>> This isn't exactly an answer to your question, but have you considered
>> using the Haskell Platform (which is recommended for most purposes) or a
>> GHC binary package?
>>
>> http://www.haskell.org/platform/
>> http://www.haskell.org/ghc/download_ghc_7_6_2#binaries
>>
>> -Karl
>>
>>
>> On Thu, Mar 28, 2013 at 9:37 AM, Josh Stratton
>> <[email protected]>wrote:
>>
>>> I recently downloaded the ghc distribution for Linux (x86_64) and had
>>> difficulty installing to my machine. The configure step seems to have
>>> completed successfully, but when I run the followup "make install", it
>>> fails suggesting that I haven't run the configure command yet.
>>>
>>> atlas => ./configure --prefix=/opt/ghc
>>> checking for path to top of build tree... /tmp/ghc-7.6.2
>>> Build platform inferred as: x86_64-unknown-linux
>>> Host platform inferred as: x86_64-unknown-linux
>>> Target platform inferred as: x86_64-unknown-linux
>>> GHC build : x86_64-unknown-linux
>>> GHC host : x86_64-unknown-linux
>>> GHC target : x86_64-unknown-linux
>>> checking for perl... /rel/map/generic-2012.18.last/bin/perl
>>> checking if your perl works in shell scripts... yes
>>> checking for a BSD-compatible install... /usr/bin/install -c
>>> checking whether ln -s works... yes
>>> checking for gsed... sed
>>> checking for gcc... /usr/bin/gcc
>>> checking for gcc... /usr/bin/gcc
>>> checking whether the C compiler works... yes
>>> checking for C compiler default output file name... a.out
>>> checking for suffix of executables...
>>> checking whether we are cross compiling... no
>>> checking for suffix of object files... o
>>> checking whether we are using the GNU C compiler... yes
>>> checking whether /usr/bin/gcc accepts -g... yes
>>> checking for /usr/bin/gcc option to accept ISO C89... none needed
>>> checking version of gcc... 4.4.6
>>> checking how to run the C preprocessor... /usr/bin/gcc -E
>>> checking whether ld understands --hash-size=31...
>>> checking whether ld understands --reduce-memory-overheads...
>>> checking for extra options to pass gcc when compiling via C... -fwrapv
>>> checking Setting up CFLAGS, LDFLAGS, IGNORE_LINKER_LD_FLAGS and
>>> CPPFLAGS... done
>>> checking Setting up CONF_CC_OPTS_STAGE0, CONF_GCC_LINKER_OPTS_STAGE0,
>>> CONF_LD_LINKER_OPTS_STAGE0 and CONF_CPP_OPTS_STAGE0... done
>>> checking Setting up CONF_CC_OPTS_STAGE1, CONF_GCC_LINKER_OPTS_STAGE1,
>>> CONF_LD_LINKER_OPTS_STAGE1 and CONF_CPP_OPTS_STAGE1... done
>>> checking Setting up CONF_CC_OPTS_STAGE2, CONF_GCC_LINKER_OPTS_STAGE2,
>>> CONF_LD_LINKER_OPTS_STAGE2 and CONF_CPP_OPTS_STAGE2... done
>>> checking for .subsections_via_symbols... no
>>> checking whether your assembler supports .ident directive... yes
>>> checking for GNU non-executable stack support... yes
>>> checking for grep that handles long lines and -e... /bin/grep
>>> checking for egrep... /bin/grep -E
>>> checking for ANSI C header files... yes
>>> checking for sys/types.h... yes
>>> checking for sys/stat.h... yes
>>> checking for stdlib.h... yes
>>> checking for string.h... yes
>>> checking for memory.h... yes
>>> checking for strings.h... yes
>>> checking for inttypes.h... yes
>>> checking for stdint.h... yes
>>> checking for unistd.h... yes
>>> checking size of void *... 8
>>> checking for ar... /usr/bin/ar
>>> checking whether /usr/bin/ar is GNU ar... yes
>>> checking for ar arguments... q
>>> checking whether ranlib is needed... no
>>> configure: creating ./config.status
>>> config.status: creating settings
>>> config.status: creating mk/config.mk
>>> config.status: creating mk/install.mk
>>> ****************************************************
>>> Configuration done, ready to 'make install'
>>> (see README and INSTALL files for more info.)
>>> ****************************************************
>>>
>>> atlas =>
>>> make install
>>> make -r --no-print-directory -f ghc.mk install BINDIST=YES
>>> NO_INCLUDE_DEPS=YES
>>> ghc.mk:122: *** Please run ./configure first. Stop.
>>> make: *** [install] Error 2
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> _______________________________________________
> 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/20130402/c3f55a72/attachment-0001.htm>
------------------------------
Message: 2
Date: Wed, 3 Apr 2013 00:05:21 +0300
From: Ovidiu D <[email protected]>
Subject: Re: [Haskell-beginners] lazy mapM
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<CAKVsE7swwBi6etdFo=d6+aXDRU-p0MFfCDzGTf48poQffLq=e...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I managed to compile and it works but I don't full understand all the type
details. I'll have to dig into Pipes and Conduits.
Thanks a lot for the code!
On Mon, Apr 1, 2013 at 5:51 AM, David McBride <[email protected]> wrote:
> I'm sorry I jacked up the code editing my email inline, the pipes section
> below main should look like this:
>
> commandProducer :: Producer String IO ()
>
> commandProducer = do
> x <- lift getLine
> if x == "exit"
> then return ()
> else P.yield x >> commandProducer
>
> displayConsumer :: PrintfArg a => Consumer a IO ()
>
> displayConsumer = forever $ P.await >>= lift . printf "Command not
> implemented (pipes): '%s'\n"
>
>
>
> On Sun, Mar 31, 2013 at 10:49 PM, David McBride <[email protected]> wrote:
>
>> Doing it the way you are trying to do it breaks the IO abstraction. In
>> order to do it you'd have to use unsafe functions. Unsafe functions are
>> bad. I'm not going to explain why but they tend to bite you as your
>> program gets more complex and weirdness starts to occur, like threads
>> ceasing operation while awaiting input is something that bit me when I went
>> down that route. So let me explain how I would do it using both pipes and
>> conduits as examples:
>>
>> import Data.Conduit as C hiding ((>+>), runPipe)
>> import System.IO
>> import Control.Monad.Trans
>> import Text.Printf.Mauke
>>
>> import Control.Pipe as P
>> import Control.Monad (forever)
>>
>> -- Source runs in the IO monad and produces Strings
>> commandSource :: Source IO String
>> commandSource = do
>> command <- liftIO getLine
>> if command == "exit"
>> then return ()
>> else do
>> C.yield command
>> commandSource -- loop to fetching new values to send down the pipe
>>
>> -- Sink runs in the IO monad and takes any printfable argument and
>> returns () when pipe completes.
>> displaySink :: PrintfArg a => Sink a IO ()
>> displaySink = do
>> m <- C.await
>> case m of
>> Nothing -> return () -- if nothing comes in, just exit
>> Just x -> do
>> liftIO $ printf "Command not implemented (conduit): '%s'\n" x
>> displaySink
>>
>> main = do
>> hSetBuffering stdout NoBuffering
>> commandSource $$ displaySink
>> runPipe $ commandProducer >+> displayConsumer
>>
>>
>> commandProducer :: PrintfArg a => Producer a String IO ()
>> commandProducer = do
>> x <- lift getLine
>> if x == "exit"
>> then return ()
>> else P.yield x >> commandProducer
>>
>> displayConsumer :: Consumer String IO ()
>> displayConsumer = forever $ P.await >>= lift . printf "Command not
>> implemented (pipes): '%s'\n"
>>
>> There are some utility function to shorten some of these definitions a
>> bit in conduit. These two examples are equivalent. But basically you are
>> creating a pipeline, the first of which gets commands until it gets an exit
>> and then sends them down the pipeline (as a string). The second piece of
>> the pipe accepts anything that is printfable and prints it. It will stop
>> when the upstream stops sending it strings to print. The point here is
>> that you have little functions that you can compose together with other
>> functions and create something bigger where none of the pieces interfere
>> with each other or break the IO abstraction.
>>
>> As to which of these libraries you should try? Conduits is a bit more
>> straight forward and has a lot more documentation and supporting
>> libraries. Pipes is a lot more flexible in that you could send things both
>> directions along the pipe in the future when you become proficient with the
>> library.
>>
>>
>>
>>
>> On Sun, Mar 31, 2013 at 9:38 PM, Ovidiu D <[email protected]> wrote:
>>
>>> I'm not sure I understand what you mean by "I know you have the best
>>> intentions in writing this, but there are pitfalls.". Anyway, here's the
>>> code which doesn't work apparently because mapM is waiting for the whole
>>> list before it goes further.
>>>
>>> prompt = ">> "
>>>
>>> commands :: [IO String]
>>> commands = readCommand : commands
>>> where readCommand = putStr prompt >> getLine
>>>
>>> display :: Show a => [ a ] -> IO ()
>>> display = mapM_ $ putStr . show
>>>
>>> executeCommand :: String -> String
>>> executeCommand = printf "Command not implemented: '%s'"
>>>
>>> processCommands :: [IO String] -> IO [ String ]
>>> processCommands = mapM processOneCommand
>>> where processOneCommand cmd = cmd >>= (return . executeCommand )
>>>
>>> main =
>>> hSetBuffering stdout NoBuffering
>>> >> processCommands commands
>>> >>= display
>>>
>>> This is just for learning purposes and I'm looking for the "haskell way
>>> to do it". My intention is to write the function processCommands such that
>>> it takes the decision to either fetch the next command from the command
>>> list (i.e. console) or to exit the application.
>>>
>>> Regarding your comment "Just know that at some point you should learn to
>>> use conduits or pipes for a much better approach to modeling things like
>>> this.". Can you point me to some documentation?
>>>
>>> Thanks!
>>>
>>>
>>> On Mon, Apr 1, 2013 at 3:53 AM, David McBride <[email protected]> wrote:
>>>
>>>> I know you have the best intentions in writing this, but there are
>>>> pitfalls. Unexpected things happen when you interleave IO in this manner,
>>>> but nonetheless, here's how you would do it.
>>>>
>>>> myGetLine = do
>>>> x <- getLine
>>>> if (x == "exit")
>>>> then return []
>>>> else do
>>>> xs <- unsafeInterleaveIO myGetLine
>>>> return (x:xs)
>>>>
>>>> main = do
>>>> x <- myGetLine
>>>> print x
>>>>
>>>> Just know that at some point you should learn to use conduits or pipes
>>>> for a much better approach to modeling things like this.
>>>>
>>>>
>>>>
>>>> On Sun, Mar 31, 2013 at 7:26 PM, Ovidiu D <[email protected]> wrote:
>>>>
>>>>> Hi again,
>>>>>
>>>>> Given the following code:
>>>>>
>>>>> g :: IO String -> IO String
>>>>>
>>>>> f :: [IO String] -> IO [ String ]
>>>>> f = mapM g
>>>>>
>>>>> The implementation of f is wrong because I would like to:
>>>>> 1. Make f behave lazy
>>>>> Its input list is made of lines read from stdin and I want it to
>>>>> process lines one by one as they are entered by the user.
>>>>>
>>>>> 2. Implement f such that it stops consuming items from the input list
>>>>> when the input item meets some condition. For example:
>>>>> isExit item = ("exit" == item)
>>>>>
>>>>> I tried to implement my own custom iteration by recursion but I got
>>>>> stuck in the combination of IO and list monads.
>>>>>
>>>>> Any help is appreciated.
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Beginners mailing list
>>>>> [email protected]
>>>>> http://www.haskell.org/mailman/listinfo/beginners
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> [email protected]
>>>> http://www.haskell.org/mailman/listinfo/beginners
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>
>
> _______________________________________________
> 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/20130403/03a4d6cc/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 58, Issue 6
****************************************