Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  How to deal with recursive/missing   dependencies? (Ming Gao)
   2. Re:  How to deal with recursive/missing dependencies?
      (Brent Yorgey)
   3.  associative arrays (Christopher Howard)
   4. Re:  associative arrays (Patrick Redmond)
   5.  shared files / environment / portability (Christopher Howard)
   6. Re:  associative arrays (Karl Voelker)
   7. Re:  shared files / environment / portability (Chadda? Fouch?)
   8.  MonadError (Dennis Raddle)
   9. Re:  shared files / environment / portability (Henk-Jan van Tuyl)


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

Message: 1
Date: Fri, 24 Aug 2012 12:17:49 +0200
From: Ming Gao <m...@gmx.de>
Subject: Re: [Haskell-beginners] How to deal with recursive/missing
        dependencies?
To: beginners@haskell.org
Message-ID: <503754cd.2030...@gmx.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,
nevermind, I solved this problem already.
In case some of you face this too: I purged ghc again, then removed .ghc 
in my home folder and reinstalled it.





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

Message: 2
Date: Fri, 24 Aug 2012 07:41:52 -0400
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] How to deal with recursive/missing
        dependencies?
To: beginners@haskell.org
Message-ID: <20120824114152.ga26...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Fri, Aug 24, 2012 at 12:17:49PM +0200, Ming Gao wrote:
> Hello,
> nevermind, I solved this problem already.
> In case some of you face this too: I purged ghc again, then removed
> .ghc in my home folder and reinstalled it.

Yes, that is probably the quickest way.  For future reference, you
could also try unregistering all the packages it said were unusable
(via ghc-pkg unregister) and then reinstalling them.

With newer versions of cabal-instal this should happen much less
often.  Don't ignore its warnings about dangerous reinstalls.

-Brent



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

Message: 3
Date: Fri, 24 Aug 2012 21:05:35 -0800
From: Christopher Howard <christopher.how...@frigidcode.com>
Subject: [Haskell-beginners] associative arrays
To: Haskell Beginners <beginners@haskell.org>
Message-ID: <50385d1f.6030...@frigidcode.com>
Content-Type: text/plain; charset="iso-8859-1"

What is typically used in Haskell circles to provide associative array
functionality? (I.e., key-value type arrays.) I'm not really looking for
efficiency so much as interface convenience. Obviously I could code it
myself based on lists or something, but I don't want to reinvent the wheel.

-- 
frigidcode.com
indicium.us

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120824/9843e5d2/attachment-0001.pgp>

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

Message: 4
Date: Sat, 25 Aug 2012 01:18:52 -0400
From: Patrick Redmond <plredm...@gmail.com>
Subject: Re: [Haskell-beginners] associative arrays
To: Christopher Howard <christopher.how...@frigidcode.com>
Cc: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <CAHUea4FWOJ=ZZ=krc6c4-h_ogeuqrcir3-y5fgvcxbzdfgs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I think that you're looking for Data.Map. Here's the docs:
http://www.haskell.org/ghc/docs/latest/html/libraries/containers-0.4.2.1/Data-Map.html
It's discussed on LYaH too:
http://learnyouahaskell.com/making-our-own-types-and-typeclasses

On Sat, Aug 25, 2012 at 1:05 AM, Christopher Howard <
christopher.how...@frigidcode.com> wrote:

> What is typically used in Haskell circles to provide associative array
> functionality? (I.e., key-value type arrays.) I'm not really looking for
> efficiency so much as interface convenience. Obviously I could code it
> myself based on lists or something, but I don't want to reinvent the wheel.
>
> --
> frigidcode.com
> indicium.us
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120825/cf36b3e1/attachment-0001.htm>

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

Message: 5
Date: Fri, 24 Aug 2012 22:09:04 -0800
From: Christopher Howard <christopher.how...@frigidcode.com>
Subject: [Haskell-beginners] shared files / environment / portability
To: Haskell Beginners <beginners@haskell.org>
Message-ID: <50386c00.1040...@frigidcode.com>
Content-Type: text/plain; charset="iso-8859-1"

I'm coding a resource tracker for a game that loads images, sounds, etc.
from files, and wondering how the program will know where the files are
located on the installation system. (With C/C++ programs I usually had
the build system hardcode the appropriate share/ directory into the
config.h file.) Assuming I package for cabal distribution, what
approaches to this problem are available to me?

(P.S. Thanks for the answer to the previous question about associative
arrays.)

-- 
frigidcode.com
indicium.us

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120824/53b03db5/attachment-0001.pgp>

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

Message: 6
Date: Fri, 24 Aug 2012 23:44:16 -0700
From: Karl Voelker <ktvoel...@gmail.com>
Subject: Re: [Haskell-beginners] associative arrays
To: Christopher Howard <christopher.how...@frigidcode.com>
Cc: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <caffow0z20cdsjb6tksbgcyhv8jpyfogiteak1pwupduyk7e...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Aug 24, 2012 at 10:05 PM, Christopher Howard
<christopher.how...@frigidcode.com> wrote:
> What is typically used in Haskell circles to provide associative array
> functionality? (I.e., key-value type arrays.) I'm not really looking for
> efficiency so much as interface convenience. Obviously I could code it
> myself based on lists or something, but I don't want to reinvent the wheel.
>

In simple situations, "coding it yourself" doesn't require much of any
code, since the Prelude comes with a lookup function for lists of
pairs:

lookup :: Eq a => a -> [(a, b)] -> Maybe b

-Karl V.



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

Message: 7
Date: Sat, 25 Aug 2012 08:45:01 +0200
From: Chadda? Fouch? <chaddai.fou...@gmail.com>
Subject: Re: [Haskell-beginners] shared files / environment /
        portability
To: Christopher Howard <christopher.how...@frigidcode.com>
Cc: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <canfjzrbekgnpzmqqkkna-xyqxuwantehj3n5yhj1ngazeb4...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Aug 25, 2012 at 8:09 AM, Christopher Howard <
christopher.how...@frigidcode.com> wrote:

> I'm coding a resource tracker for a game that loads images, sounds, etc.
> from files, and wondering how the program will know where the files are
> located on the installation system. (With C/C++ programs I usually had
> the build system hardcode the appropriate share/ directory into the
> config.h file.) Assuming I package for cabal distribution, what
> approaches to this problem are available to me?
>
> (P.S. Thanks for the answer to the previous question about associative
> arrays.)
>

Cabal includes a slightly limited system for that :
http://www.haskell.org/ghc/docs/7.0.2/html/Cabal/authors.html#paths-module
http://neilmitchell.blogspot.fr/2008/02/adding-data-files-using-cabal.html

-- 
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120825/00df3136/attachment-0001.htm>

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

Message: 8
Date: Sat, 25 Aug 2012 00:30:23 -0700
From: Dennis Raddle <dennis.rad...@gmail.com>
Subject: [Haskell-beginners] MonadError
To: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <cakxlvor0puhgjeijqjrkjajjifdyhkta21grhtyaatz4qcy...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I'm enjoying writing code that uses the Error monad to provide errors,
which I can catch and rethrow to add context. Kind of like getting a stack
trace with any context I want every time an error happens.

In most cases I use monad transformers, so the actual monad type would be
something like "ErrorT String (State Int) a"

But much of my code that handles errors doesn't need to know the entire
context. It uses throwError, but otherwise doesn't care anything else about
the type of the monadic computation. I.e., it needs to "know" that it's
inside a monadic computation of a typeclass MonadError.

So I discovered that I could declare a function like this:

x :: MonadError String m => Float -> m Float
x y = if y == 0
  then throwError "zero"
  else return y

My awareness of class constraints is vague, so as I worked on this problem
I knew in a fuzzy way it was going to look something like that, but I had
to experiment.

Also, because I put "String" in the class constraint, I need to turn on
FlexibleContexts.

So my question is, how would I do it without making "String" explicit?

If I put

x:: MonadError e m => Float -> m Float
x y = if y == 0
  then throwError "zero"
  else return y

I get errors saying "couldn't match expected type e against inferred type
[Char]" and something about functional dependencies

I fiddled with it a bit but couldn't make it work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120825/9b6a854d/attachment-0001.htm>

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

Message: 9
Date: Sat, 25 Aug 2012 10:08:01 +0200
From: "Henk-Jan van Tuyl" <hjgt...@chello.nl>
Subject: Re: [Haskell-beginners] shared files / environment /
        portability
To: "Haskell Beginners" <beginners@haskell.org>, "Christopher Howard"
        <christopher.how...@frigidcode.com>
Message-ID: <op.wjk7jnogpz0...@zen5.arnhem.chello.nl>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Sat, 25 Aug 2012 08:09:04 +0200, Christopher Howard  
<christopher.how...@frigidcode.com> wrote:

> I'm coding a resource tracker for a game that loads images, sounds, etc.
> from files, and wondering how the program will know where the files are
> located on the installation system. (With C/C++ programs I usually had
> the build system hardcode the appropriate share/ directory into the
> config.h file.) Assuming I package for cabal distribution, what
> approaches to this problem are available to me?


You can find an example in wxAsteroids[0], look at the main function.

Met vriendelijke groet,
Henk-Jan van Tuyl

[0] http://hackage.haskell.org/package/wxAsteroids


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--



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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 50, Issue 27
*****************************************

Reply via email to