Cui Liqiang | 28 Oct 13:00 2014
Picon

Haskell typing question

Thanks for your help, your suggestion works.

But I still don’t quite understand. In the following line:
caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l)),
After applying digitToInt, the type of ‘x’ in the expression above is Int indeed, but Haskell consider the ’10.0’ to be a Int, is it?




----------------------------------------------------------------------------------------------------------------------------
Hi,
I am doing an exercise in Haskell, which is converting a string like ?$123.312? to double value. Below is my code:

module Main where
import Data.Char

caluInt l = foldl1 (\acc x -> acc * 10 + x) (map digitToInt l)
caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l))

convert(x:xs) =
let num = [e | e <- xs, e /= ',']
intPart = takeWhile (/='.') num
decimalPart = tail(dropWhile (/='.') num)
in (caluInt intPart) + (caluDecimal decimalPart)


And I got an error in this line: caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l)),
which says:
No instance for (Fractional Int) arising from a use of `/'
Possible fix: add an instance declaration for (Fractional Int)
In the first argument of `(+)', namely `acc / 10.0'
In the expression: acc / 10.0 + x
In the first argument of `foldr1', namely
`(\ x acc -> acc / 10.0 + x)'


Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell I want a Fractional?
--
Cui Liqiang


Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell
I want a Fractional?

Because digitToInt means exactly what it says. If you want it to become
something other than Int, apply fromIntegral to its result.
<div>
<div>Thanks for your help, your suggestion works.</div>
<div><br></div>
<div>But I still don&rsquo;t quite understand. In the following line:</div>
<div>
<span class="Apple-tab-span">	</span>caluDecimal l = (foldr1 (\x acc -&gt; acc / 10.0 + x) (map digitToInt l)),</div>
<div>After applying digitToInt, the type of &lsquo;x&rsquo; in the expression above is Int indeed, but Haskell consider the &rsquo;10.0&rsquo; to be a Int, is it?</div>
<div><span><br></span></div>
<div><span><br></span></div>
<div><span><br></span></div>
<div><span><br></span></div>
<div><span>----------------------------------------------------------------------------------------------------------------------------</span></div>
<div>
<div>Hi,</div>
<div>I am doing an exercise in Haskell, which is converting a string like ?$123.312? to double value. Below is my code:</div>
<div><br></div>
<div>module Main where</div>
<div>import Data.Char</div>
<div><br></div>
<div>caluInt l = foldl1 (\acc x -&gt; acc * 10 + x) (map digitToInt l)</div>
<div>caluDecimal l = (foldr1 (\x acc -&gt; acc / 10.0 + x) (map digitToInt l))</div>
<div><br></div>
<div>convert(x:xs) =</div>
<div>let num = [e | e &lt;- xs, e /= ',']</div>
<div>intPart = takeWhile (/='.') num</div>
<div>decimalPart = tail(dropWhile (/='.') num)</div>
<div>in (caluInt intPart) + (caluDecimal decimalPart)</div>
<div><br></div>
<div><br></div>
<div>And I got an error in this line: caluDecimal l = (foldr1 (\x acc -&gt; acc / 10.0 + x) (map digitToInt l)),</div>
<div>which says:</div>
<div>No instance for (Fractional Int) arising from a use of `/'</div>
<div>Possible fix: add an instance declaration for (Fractional Int)</div>
<div>In the first argument of `(+)', namely `acc / 10.0'</div>
<div>In the expression: acc / 10.0 + x</div>
<div>In the first argument of `foldr1', namely</div>
<div>`(\ x acc -&gt; acc / 10.0 + x)'</div>
<div><br></div>
<div><br></div>
<div>Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell I want a Fractional?</div>
<div>--</div>
<div>Cui Liqiang</div>
</div>
<div><br></div>
<div><br></div>
<blockquote type="cite">
<div>Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell</div>
<div>I want a Fractional?</div>
</blockquote>
<div><br></div>
<div>Because digitToInt means exactly what it says. If you want it to become</div>
<div>something other than Int, apply fromIntegral to its result.</div>
</div>
Stefan Höck | 28 Oct 05:49 2014
Picon

Cabal-install of local package

Dear list

Like many other I seem to be struggling with some of the concepts of
cabal and cabal-install. For the records: I use cabal-install 1.20.0.3
and ghc 7.8.3 on arch linux.

For starters, I implemented my own idea of an improved prelude, called
the package efa-prelude and the module it exports Efa.Prelude. I then
built the package and installed it using `cabal install --user`.
This worked and a folder for the library was created at
"$HOME/.cabal/lib/x86_64-linux-ghc-7.8.3/efa-prelude-0.1.0".
I also registered the library using `cabal register --user` and
now cabal prints some information about the package when I type
`cabal info efa-prelude`. I am also able to import Efa.Prelude into
ghci.

However, when I now try to use this library in another local project
using a sandbox this time, I can build the project but
when I try to install it into the sandbox I get the following error
message:

    Resolving dependencies...
    cabal: Could not resolve dependencies:
    trying: test-0.1.0 (user goal)
    next goal: efa-prelude (dependency of test-0.1.0)
    Dependency tree exhaustively searched.

I just tried and the install works if I do it outside of a sandbox.
Obviously I am missing something crucial here. Could somebody please point me
in the right direction what is needed to make my own packages available
in a sanboxed install?

Thanks for your time

Stefan

Jason T. Slack-Moehrle | 28 Oct 04:11 2014
Picon

error compiling haskell-src-1.0.1.4

I am trying to compile haskell-platform on an AWS instance. The version: haskell-platform-2011.2.0.0

It was going OK, but now I am getting an error I dont know how to solve:

Building haskell-src-1.0.1.4...
[1 of 6] Compiling Language.Haskell.Syntax ( Language/Haskell/Syntax.hs, dist/build/Language/Haskell/Syntax.o )
[2 of 6] Compiling Language.Haskell.Pretty ( Language/Haskell/Pretty.hs, dist/build/Language/Haskell/Pretty.o )
[3 of 6] Compiling Language.Haskell.ParseMonad ( Language/Haskell/ParseMonad.hs, dist/build/Language/Haskell/ParseMonad.o )
[4 of 6] Compiling Language.Haskell.ParseUtils ( Language/Haskell/ParseUtils.hs, dist/build/Language/Haskell/ParseUtils.o )
[5 of 6] Compiling Language.Haskell.Lexer ( Language/Haskell/Lexer.hs, dist/build/Language/Haskell/Lexer.o )
[6 of 6] Compiling Language.Haskell.Parser ( dist/build/Language/Haskell/Parser.hs, dist/build/Language/Haskell/Parser.o )

dist/build/Language/Haskell/Parser.hs:0:36:
    The function `runParserWithMode' is applied to 8 arguments,
    but its type `ParseMode -> P a0 -> String -> ParseResult a0'
    has only three
    In the expression: runParserWithMode mode parse 1 3 4 3 4 2
    In an equation for `parseModuleWithMode':
        parseModuleWithMode mode = runParserWithMode mode parse 1 3 4 3 4 2

Error:
Building the haskell-src-1.0.1.4 package failed
make: *** [build.stamp] Error 2

Can anyone help me get past this?

Best,
Jason


<div><div dir="ltr">
<div class="gmail_default">I am trying to compile haskell-platform on an AWS instance. The version: haskell-platform-2011.2.0.0</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">It was going OK, but now I am getting an error I dont know how to solve:</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">
<div class="gmail_default">Building haskell-src-1.0.1.4...</div>
<div class="gmail_default">[1 of 6] Compiling Language.Haskell.Syntax ( Language/Haskell/Syntax.hs, dist/build/Language/Haskell/Syntax.o )</div>
<div class="gmail_default">[2 of 6] Compiling Language.Haskell.Pretty ( Language/Haskell/Pretty.hs, dist/build/Language/Haskell/Pretty.o )</div>
<div class="gmail_default">[3 of 6] Compiling Language.Haskell.ParseMonad ( Language/Haskell/ParseMonad.hs, dist/build/Language/Haskell/ParseMonad.o )</div>
<div class="gmail_default">[4 of 6] Compiling Language.Haskell.ParseUtils ( Language/Haskell/ParseUtils.hs, dist/build/Language/Haskell/ParseUtils.o )</div>
<div class="gmail_default">[5 of 6] Compiling Language.Haskell.Lexer ( Language/Haskell/Lexer.hs, dist/build/Language/Haskell/Lexer.o )</div>
<div class="gmail_default">[6 of 6] Compiling Language.Haskell.Parser ( dist/build/Language/Haskell/Parser.hs, dist/build/Language/Haskell/Parser.o )</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">dist/build/Language/Haskell/Parser.hs:0:36:</div>
<div class="gmail_default">&nbsp; &nbsp; The function `runParserWithMode' is applied to 8 arguments,</div>
<div class="gmail_default">&nbsp; &nbsp; but its type `ParseMode -&gt; P a0 -&gt; String -&gt; ParseResult a0'</div>
<div class="gmail_default">&nbsp; &nbsp; has only three</div>
<div class="gmail_default">&nbsp; &nbsp; In the expression: runParserWithMode mode parse 1 3 4 3 4 2</div>
<div class="gmail_default">&nbsp; &nbsp; In an equation for `parseModuleWithMode':</div>
<div class="gmail_default">&nbsp; &nbsp; &nbsp; &nbsp; parseModuleWithMode mode = runParserWithMode mode parse 1 3 4 3 4 2</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Error:</div>
<div class="gmail_default">Building the haskell-src-1.0.1.4 package failed</div>
<div class="gmail_default">make: *** [build.stamp] Error 2</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Can anyone help me get past this?</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Best,</div>
<div class="gmail_default">Jason</div>
<div class="gmail_default"><br></div>
<div class="gmail_default"><br></div>
</div>
</div></div>
Ovidiu Deac | 27 Oct 21:47 2014
Picon

can somebody explain the type of this expression?

Prelude> let f x = x * 2
Prelude> :t f
f :: Num a => a -> a

The typeclass Num is defined like this:

class  Num a  where
    (+), (-), (*)       :: a -> a -> a
    ...

...which means that the operator (*) expects two parameters of type a and returns a value of type a.

Since the definition of expr looks like this:
Prelude> let f x = x * 2

...and 2 is an Int, I would expect that the type inferred for (*)  is (Int -> Int -> Int) and thus f should be (Int -> Int)

Can somebody explain this?

Thanks!
<div><div dir="ltr">
<div>Prelude&gt; let f x = x * 2<br>Prelude&gt; :t f<br>f :: Num a =&gt; a -&gt; a<br><br>The typeclass Num is defined like this:<br><br>class&nbsp; Num a&nbsp; where<br>&nbsp;&nbsp;&nbsp; (+), (-), (*)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :: a -&gt; a -&gt; a<br>&nbsp;&nbsp;&nbsp; ...<br><br>...which means that the operator (*) expects two parameters of type a and returns a value of type a.<br><br>Since the definition of expr looks like this:<br>Prelude&gt; let f x = x * 2<br><br>...and 2 is an Int, I would expect that the type inferred for (*)&nbsp; is (Int -&gt; Int -&gt; Int) and thus f should be (Int -&gt; Int)<br><br>Can somebody explain this?<br><br>
</div>Thanks!<br>
</div></div>
Cui Liqiang | 26 Oct 23:52 2014
Picon

Haskell typing question

Hi,
I am doing an exercise in Haskell, which is converting a string like “$123.312” to double value. Below is my code:

module Main where
    import Data.Char

    caluInt l = foldl1 (\acc x -> acc * 10 + x) (map digitToInt l)
    caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l))

    convert(x:xs) = 
        let num = [e | e <- xs, e /= ',']
            intPart = takeWhile (/='.') num
            decimalPart = tail(dropWhile (/='.') num)
        in (caluInt intPart) + (caluDecimal decimalPart)

And I got an error in this line:     caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l)),
which says:

    No instance for (Fractional Int) arising from a use of `/'

    Possible fix: add an instance declaration for (Fractional Int)

    In the first argument of `(+)', namely `acc / 10.0'

    In the expression: acc / 10.0 + x

    In the first argument of `foldr1', namely

      `(\ x acc -> acc / 10.0 + x)'


Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell I want a Fractional?
-- 
Cui Liqiang
<div>
<div>
                    Hi,</div>
<div>I am doing an exercise in Haskell, which is converting a string like &ldquo;$123.312&rdquo; to double value. Below is my code:</div>
<div>
<div><br></div>
<div>module Main where</div>
<div>&nbsp; &nbsp; import Data.Char</div>
<div><br></div>
<div>&nbsp; &nbsp; caluInt l = foldl1 (\acc x -&gt; acc * 10 + x) (map digitToInt l)</div>
<div>&nbsp; &nbsp; caluDecimal l = (foldr1 (\x acc -&gt; acc / 10.0 + x) (map digitToInt l))</div>
<div><br></div>
<div>&nbsp; &nbsp; convert(x:xs) =&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; let num = [e | e &lt;- xs, e /= ',']</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intPart = takeWhile (/='.') num</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; decimalPart = tail(dropWhile (/='.') num)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; in (caluInt intPart) + (caluDecimal decimalPart)</div>
</div>
<div><br></div>
<div>And I got an error in this line: &nbsp; &nbsp; caluDecimal l = (foldr1 (\x acc -&gt; acc / 10.0 + x) (map digitToInt l)),</div>
<div>which says:</div>
<div>
<p>&nbsp; &nbsp;&nbsp;No instance for (Fractional Int) arising from a use of `/'</p>
<p>&nbsp; &nbsp; Possible fix: add an instance declaration for (Fractional Int)</p>
<p>&nbsp; &nbsp; In the first argument of `(+)', namely `acc / 10.0'</p>
<p>&nbsp; &nbsp; In the expression: acc / 10.0 + x</p>
<p>&nbsp; &nbsp; In the first argument of `foldr1', namely</p>
<p>&nbsp; &nbsp; &nbsp; `(\ x acc -&gt; acc / 10.0 + x)'</p>
</div>
                <div>
<div><br></div>
<div>Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell I want a Fractional?</div>
<div>--&nbsp;</div>
<div>Cui Liqiang</div>
</div>
</div>
Jan Snajder | 26 Oct 22:34 2014
Picon

Lazy state + IO not lazy?

Dear Haskellers,

I'm confused with the behaviour of a lazy state monad when combined with
an IO monad. Look at this:

ghci> Control.Monad.State.Lazy.evalState (head `fmap` mapM return
(1:undefined)) 0
1

ghci> Control.Monad.State.Lazy.evalStateT (head `fmap` mapM return
(1:undefined)) 0
*** Exception: Prelude.undefined

I would have expected the second case to behave identically to the first
case. Why is this not the case?

Cheers,
Jan
Jeffrey Brown | 25 Oct 20:04 2014
Picon

Installation problems

Hi,

In trying to install Tidal, following something that worked for someone else who was getting an error similar to one I got, I ran ghc-clang-wrapper. I believe it was after that that cabal install stopped working, and I lost a lot of libraries that used to exist, such as Sound.MIDI:

    GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
    Loading package ghc-prim ... linking ... done.
    Loading package integer-gmp ... linking ... done.
    Loading package base ... linking ... done.
    Prelude> import Sound.MIDI
    
    <no location info>:
        Could not find module ‘Sound.MIDI’
        It is not a module in the current program, or in any known package.
    Prelude>

When I try to reinstall a library that used to exist -- e.g. "hosc", below -- via cabal install, I now get a giant slew of failures.

Any ideas?

Many thanks,
Jeff

    sh-3.2# cabal install hosc
    Resolving dependencies...
    In order, the following will be installed:
    binary-0.7.2.2 (new version)
    data-binary-ieee754-0.4.4 (reinstall) changes: base-4.7.0.1 added,
    binary-0.7.2.2 added
    network-2.6.0.2 (new package)
    text-1.2.0.0 (new package)
    blaze-builder-0.3.3.4 (reinstall) changes: base-4.7.0.1 added,
    bytestring-0.10.4.0 added, text-1.2.0.0 added
    hosc-0.15 (new version)
    Warning: Note that reinstalls are always dangerous. Continuing anyway...
    Downloading binary-0.7.2.2...
    Configuring network-2.6.0.2...
    Configuring text-1.2.0.0...
    Failed to install network-2.6.0.2
    Build log ( /var/root/.cabal/logs/network-2.6.0.2.log ):
    Failed to install text-1.2.0.0
    Build log ( /var/root/.cabal/logs/text-1.2.0.0.log ):
    Configuring binary-0.7.2.2...
    Failed to install binary-0.7.2.2
    Build log ( /var/root/.cabal/logs/binary-0.7.2.2.log ):
    cabal: Error: some packages failed to install:
    binary-0.7.2.2 failed during the configure step. The exception was:
    user error (<command line>: cannot satisfy -package-id
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or
    recursive dependencies:
    base-4.7.0.1-df210ede1eb79477fef5662549c32927
    bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa
    containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721
    deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4
    directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72
    process-1.2.0.0-3a472e9c66165e506513ea8f145681a0
    time-1.4.2-d6766dce59812a4b19375d9595549a8b
    unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703
    (use -v for more information)
    )
    blaze-builder-0.3.3.4 depends on text-1.2.0.0 which failed to install.
    data-binary-ieee754-0.4.4 depends on binary-0.7.2.2 which failed to install.
    hosc-0.15 depends on binary-0.7.2.2 which failed to install.
    network-2.6.0.2 failed during the configure step. The exception was:
    user error (<command line>: cannot satisfy -package-id
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or
    recursive dependencies:
    base-4.7.0.1-df210ede1eb79477fef5662549c32927
    bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa
    containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721
    deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4
    directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72
    process-1.2.0.0-3a472e9c66165e506513ea8f145681a0
    time-1.4.2-d6766dce59812a4b19375d9595549a8b
    unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703
    (use -v for more information)
    )
    text-1.2.0.0 failed during the configure step. The exception was:
    user error (<command line>: cannot satisfy -package-id
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:
    Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or
    recursive dependencies:
    base-4.7.0.1-df210ede1eb79477fef5662549c32927
    bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa
    containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721
    deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4
    directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72
    process-1.2.0.0-3a472e9c66165e506513ea8f145681a0
    time-1.4.2-d6766dce59812a4b19375d9595549a8b
    unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703
    (use -v for more information)
    )

<div><div dir="ltr">
<div>
<div>Hi,</div>
<div><br></div>
<div>In trying to install Tidal, following something that worked for someone else who was getting an error similar to one I got, I ran <a href="https://gist.github.com/mzero/7245290#file-ghc-clang-wrapper">ghc-clang-wrapper</a>.&nbsp;I believe it was after that that cabal install stopped working, and I lost a lot of libraries that used to exist, such as Sound.MIDI:</div>
<div><br></div>
<div>&nbsp; &nbsp; GHCi, version 7.8.3: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a> &nbsp;:? for help</div>
<div>&nbsp; &nbsp; Loading package ghc-prim ... linking ... done.</div>
<div>&nbsp; &nbsp; Loading package integer-gmp ... linking ... done.</div>
<div>&nbsp; &nbsp; Loading package base ... linking ... done.</div>
<div>&nbsp; &nbsp; Prelude&gt; import Sound.MIDI</div>
<div>&nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &lt;no location info&gt;:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Could not find module &lsquo;Sound.MIDI&rsquo;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; It is not a module in the current program, or in any known package.</div>
<div>&nbsp; &nbsp; Prelude&gt;</div>
<div><br></div>
<div>When I try to reinstall a library that used to exist -- e.g. "hosc", below -- via cabal install, I now get a giant slew of failures.</div>
<div><br></div>
<div>Any ideas?</div>
<div><br></div>
<div>Many thanks,</div>
<div>Jeff</div>
<div><br></div>
<div>&nbsp; &nbsp; sh-3.2# cabal install hosc</div>
<div>&nbsp; &nbsp; Resolving dependencies...</div>
<div>&nbsp; &nbsp; In order, the following will be installed:</div>
<div>&nbsp; &nbsp; binary-0.7.2.2 (new version)</div>
<div>&nbsp; &nbsp; data-binary-ieee754-0.4.4 (reinstall) changes: base-4.7.0.1 added,</div>
<div>&nbsp; &nbsp; binary-0.7.2.2 added</div>
<div>&nbsp; &nbsp; network-2.6.0.2 (new package)</div>
<div>&nbsp; &nbsp; text-1.2.0.0 (new package)</div>
<div>&nbsp; &nbsp; blaze-builder-0.3.3.4 (reinstall) changes: base-4.7.0.1 added,</div>
<div>&nbsp; &nbsp; bytestring-0.10.4.0 added, text-1.2.0.0 added</div>
<div>&nbsp; &nbsp; hosc-0.15 (new version)</div>
<div>&nbsp; &nbsp; Warning: Note that reinstalls are always dangerous. Continuing anyway...</div>
<div>&nbsp; &nbsp; Downloading binary-0.7.2.2...</div>
<div>&nbsp; &nbsp; Configuring network-2.6.0.2...</div>
<div>&nbsp; &nbsp; Configuring text-1.2.0.0...</div>
<div>&nbsp; &nbsp; Failed to install network-2.6.0.2</div>
<div>&nbsp; &nbsp; Build log ( /var/root/.cabal/logs/network-2.6.0.2.log ):</div>
<div>&nbsp; &nbsp; Failed to install text-1.2.0.0</div>
<div>&nbsp; &nbsp; Build log ( /var/root/.cabal/logs/text-1.2.0.0.log ):</div>
<div>&nbsp; &nbsp; Configuring binary-0.7.2.2...</div>
<div>&nbsp; &nbsp; Failed to install binary-0.7.2.2</div>
<div>&nbsp; &nbsp; Build log ( /var/root/.cabal/logs/binary-0.7.2.2.log ):</div>
<div>&nbsp; &nbsp; cabal: Error: some packages failed to install:</div>
<div>&nbsp; &nbsp; binary-0.7.2.2 failed during the configure step. The exception was:</div>
<div>&nbsp; &nbsp; user error (&lt;command line&gt;: cannot satisfy -package-id</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or</div>
<div>&nbsp; &nbsp; recursive dependencies:</div>
<div>&nbsp; &nbsp; base-4.7.0.1-df210ede1eb79477fef5662549c32927</div>
<div>&nbsp; &nbsp; bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa</div>
<div>&nbsp; &nbsp; containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721</div>
<div>&nbsp; &nbsp; deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4</div>
<div>&nbsp; &nbsp; directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72</div>
<div>&nbsp; &nbsp; process-1.2.0.0-3a472e9c66165e506513ea8f145681a0</div>
<div>&nbsp; &nbsp; time-1.4.2-d6766dce59812a4b19375d9595549a8b</div>
<div>&nbsp; &nbsp; unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703</div>
<div>&nbsp; &nbsp; (use -v for more information)</div>
<div>&nbsp; &nbsp; )</div>
<div>&nbsp; &nbsp; blaze-builder-0.3.3.4 depends on text-1.2.0.0 which failed to install.</div>
<div>&nbsp; &nbsp; data-binary-ieee754-0.4.4 depends on binary-0.7.2.2 which failed to install.</div>
<div>&nbsp; &nbsp; hosc-0.15 depends on binary-0.7.2.2 which failed to install.</div>
<div>&nbsp; &nbsp; network-2.6.0.2 failed during the configure step. The exception was:</div>
<div>&nbsp; &nbsp; user error (&lt;command line&gt;: cannot satisfy -package-id</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or</div>
<div>&nbsp; &nbsp; recursive dependencies:</div>
<div>&nbsp; &nbsp; base-4.7.0.1-df210ede1eb79477fef5662549c32927</div>
<div>&nbsp; &nbsp; bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa</div>
<div>&nbsp; &nbsp; containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721</div>
<div>&nbsp; &nbsp; deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4</div>
<div>&nbsp; &nbsp; directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72</div>
<div>&nbsp; &nbsp; process-1.2.0.0-3a472e9c66165e506513ea8f145681a0</div>
<div>&nbsp; &nbsp; time-1.4.2-d6766dce59812a4b19375d9595549a8b</div>
<div>&nbsp; &nbsp; unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703</div>
<div>&nbsp; &nbsp; (use -v for more information)</div>
<div>&nbsp; &nbsp; )</div>
<div>&nbsp; &nbsp; text-1.2.0.0 failed during the configure step. The exception was:</div>
<div>&nbsp; &nbsp; user error (&lt;command line&gt;: cannot satisfy -package-id</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff:</div>
<div>&nbsp; &nbsp; Cabal-1.20.0.2-b862897337f86101d0e1a35135984eff is unusable due to missing or</div>
<div>&nbsp; &nbsp; recursive dependencies:</div>
<div>&nbsp; &nbsp; base-4.7.0.1-df210ede1eb79477fef5662549c32927</div>
<div>&nbsp; &nbsp; bytestring-0.10.4.0-4aa78c8ca7b6b65993eefc131f7d94fa</div>
<div>&nbsp; &nbsp; containers-0.5.5.1-0d8db9193d3e3371e0142bcc8a4a0721</div>
<div>&nbsp; &nbsp; deepseq-1.3.0.2-8f63133c1b77f3b3190f04893cf340e4</div>
<div>&nbsp; &nbsp; directory-1.2.1.0-af5afa2b9b551d3fec1a32d6bfd8bd72</div>
<div>&nbsp; &nbsp; process-1.2.0.0-3a472e9c66165e506513ea8f145681a0</div>
<div>&nbsp; &nbsp; time-1.4.2-d6766dce59812a4b19375d9595549a8b</div>
<div>&nbsp; &nbsp; unix-2.7.0.1-8adde3f1f2079286da56b30898c2d703</div>
<div>&nbsp; &nbsp; (use -v for more information)</div>
<div>&nbsp; &nbsp; )</div>
</div>
<div><br></div>
</div></div>
Christian Sperandio | 25 Oct 14:07 2014
Picon

Use mysql-simple (OS X and dymanic library trouble)

Hi,


I’d like to use Haskell for some processing on a MySQL database. Currently, I use Java program to do that but I’d like to change.And an important information, I’m working on OS X Maverick and I use EclipseFP.

I installed mysql-simple package. I had some troubles.
First, I had to download pcre to get a pcre.h I put into the /usr/include dir. 
After, to link the mysql-simple package I did an export LD_LIBRARY_PATH=/usr/local/mysql-5.6.11-osx10.7-x86_64/lib. Thus, the library libmysqlclient.18.dylib was found.
All stuff above were done by command line.

Now, I want to code a simple program: 

module Main where

import Database.MySQL.Simple


main::IO()
main = undefined

hello :: IO Int
hello = do
   conn <- connect defaultConnectInfo
   [Only i] <- query_ conn "select 2 + 2"
   return i

But when I try to launch a repl from EclipseFP, I’ve got this error: 
Loading package mysql-0.1.1.7 ... <command line>: can't load .so/.DLL for: /Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib (dlopen(/Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib, 9): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib
  Reason: image not found)

How can I set the place of this library ? I read some stuff on the web but I don’t understand everything :(

Thanks for your help.

Chris

<div>Hi,<div><br></div>
<div><br></div>
<div>I&rsquo;d like to use Haskell for some processing on a MySQL database. Currently, I use Java program to do that but I&rsquo;d like to change.And an important information, I&rsquo;m working on OS X Maverick and I use EclipseFP.</div>
<div><br></div>
<div>I installed mysql-simple package. I had some troubles.</div>
<div>First, I had to download pcre to get a pcre.h I put into the /usr/include dir.&nbsp;</div>
<div>After, to link the mysql-simple package I did an export LD_LIBRARY_PATH=/usr/local/mysql-5.6.11-osx10.7-x86_64/lib. Thus, the library&nbsp;libmysqlclient.18.dylib was found.</div>
<div>All stuff above were done by command line.</div>
<div><br></div>
<div>Now, I want to code a simple program:&nbsp;</div>
<div><br></div>
<div>
<div>module<span> </span><span>Main</span><span> </span>where</div>
<div><br></div>
<div>
<span>import</span><span> </span>Database.MySQL.Simple</div>
<div><br></div>
<div><br></div>
<div>main<span>::</span><span>IO</span><span>()</span>
</div>
<div>main <span>=</span> undefined</div>
<div><br></div>
<div>hello <span>::</span> <span>IO Int</span>
</div>
<div>hello <span>=</span> <span>do</span>
</div>
<div>&nbsp;&nbsp; conn <span>&lt;-</span> connect defaultConnectInfo</div>
<div>
<span>&nbsp;&nbsp; [</span><span>Only</span> i<span>]</span> <span>&lt;-</span> query_ conn <span>"select 2 + 2"</span>
</div>
<div>&nbsp;&nbsp; return i</div>
</div>
<div><br></div>
<div>But when I try to launch a repl from EclipseFP, I&rsquo;ve got this error:&nbsp;</div>
<div>
<div>Loading package mysql-0.1.1.7 ... &lt;command line&gt;: can't load .so/.DLL for: /Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib (dlopen(/Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib, 9): Library not loaded: libmysqlclient.18.dylib</div>
<div>&nbsp; Referenced from: /Users/batman/Library/Haskell/ghc-7.8.3-x86_64/lib/mysql-0.1.1.7/libHSmysql-0.1.1.7-ghc7.8.3.dylib</div>
<div>&nbsp; Reason: image not found)</div>
<div><br></div>
<div>How can I set the place of this library ? I read some stuff on the web but I don&rsquo;t understand everything :(</div>
<div><br></div>
<div>Thanks for your help.</div>
<div><br></div>
<div>Chris</div>
<div><br></div>
</div>
</div>
Rohit Sharma | 25 Oct 05:31 2014
Picon

Question on syntax

All,

I started learning haskell very recently and have a question on the pattern matching style for lists.

In the below snippet i.e. "(x:xs)" why do we went with round braces and not square? I know we are using cons that tells this is not a tuple but would it not make more sense to write something like [x:xs] instead of (x:xs), i thought round braces was used for pair/tuples?

safeHead [] = Nothing
safeHead (x:xs) = Just x

Thanks,
Rohit
<div><div dir="ltr">All,<div><br></div>
<div>I started learning haskell very recently and have a question on the pattern matching style for lists.<div><br></div>
<div>In the below snippet i.e. "(x:xs)" why do we went with round braces and not square? I know we are using cons that tells this is not a tuple but would it not make more sense to write something like [x:xs] instead of (x:xs), i thought round braces was used for pair/tuples?</div>
<div><br></div>
<div>safeHead [] = Nothing</div>
<div>safeHead (x:xs) = Just x</div>
</div>
<div><br></div>
<div>Thanks,</div>
<div>Rohit</div>
</div></div>
Julius Gedvilas | 24 Oct 15:30 2014
Picon

GHCi error msgs

How difficult would it be to change format of GHCi compile-time error-messages of type "couldn't match expected type"?
<div><div dir="ltr">How difficult would it be to change format of GHCi compile-time error-messages of type "couldn't match expected type"?</div></div>
Dimitri DeFigueiredo | 20 Oct 20:57 2014
Picon

learning lazy evaluation

I found an interesting situation while making recursive calls that I am 
trying to understand. I re-wrote the 'minimum' function from the prelude 
as such:

minimum_bug :: (Ord a) => [a] -> a
minimum_bug  [x] = x
minimum_bug  (x:xs) | x > minimum_bug xs = minimum_bug xs
                     | otherwise          = x

(I understand I should be using something like "minbug xs = foldr1 min 
xs" for this, but bare with me)

The interesting thing is that the function has exponential time 
behavior. In a way, that makes sense as I am making two recursive calls. 
But I was expecting GHC to be smart enough to transform it into 
something like:

minimum_bug' :: (Ord a) => [a] -> a
minimum_bug'  [x] = x
minimum_bug'  (x:xs) | x > y      = y
                      | otherwise  = x
                         where y = minimum_bug' xs

(This one always works as expected)

I understand that lazy evaluation implies memoization in some cases.
When does GHC only use memoization to avoid this kind of behavior?

Another interesting fact is that in my simple tests the exponential 
behavior does NOT occur when I pass the function a list in sorted order.

main = do putStrLn "started - in order list"
           putStrLn $ show $ minimum_bug [1..30000]  -- no problem
           putStrLn "started - out of order list"
           putStrLn $ show $ minimum_bug [27,26..1]  -- don't do this 
with large numbers!
           putStrLn "done!"

It's not clear to me how the sorted list is able to escape the 
exponential slow down.

Cheers,

Dimitri


Gmane