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: Handling a MonadError (Christopher Howard)
2. Re: How to avoid repeating code (Federico Mastellone)
3. Install on "foreign" server problems (Lawrence Bottorff)
4. Re: Install on "foreign" server problems (Michael Snoyman)
5. Re: Install on "foreign" server problems (Michael Snoyman)
----------------------------------------------------------------------
Message: 1
Date: Mon, 30 May 2011 11:35:50 -0800
From: Christopher Howard <[email protected]>
Subject: Re: [Haskell-beginners] Handling a MonadError
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Related question: Could you explain the typeclass definition for
MonadError to me?:
class (Monad m) => MonadError e m | m -> e where
throwError :: e -> m a
catchError :: m a -> (e -> m a) -> m a
More specifically: Why is there a pipe symbol followed by what looks
like a function definition in the "class" line? The typeclass
definitions from the tutorials I went through were simpler, like:
class BasicEq a where
isEqual :: a -> a -> Bool
--
frigidcode.com
theologia.indicium.us
------------------------------
Message: 2
Date: Mon, 30 May 2011 16:44:32 -0300
From: Federico Mastellone <[email protected]>
Subject: Re: [Haskell-beginners] How to avoid repeating code
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thanks again Daniel!!
I've been looking at the Edison package, it has a big class
hierarchy without default implementations using functional dependencies and
I found tidier doing something similar with associated types.
Writing default implementations continues to be troublesome.
Here is an example adding an elems function to the Collection class
elems :: c -> [Elem c]
I can't write on the MultiMapClass class a default implementation
for getValueList like this
getValueList :: Key m -> m -> [Value m]
getValueList k m = elems $ getValues k m
because elems returns
[Elem (Coll m)]
so I have to write
getValueList :: Key m -> m -> [Elem (Coll m)]
and it doesn't matter that this means the same for the implementations I
have
Elem (Set.Set a) ~ Value (MultiMap k v)
and
Elem IntSet.IntSet ~ Value IntMultiMap
Now when using classes like this you need to need to think twice when
coding! Typing becomes much more complicated.
I don't know if I am too object oriented or is the lack of IDEs but reusing
code, grouping together code with similarities and managing many modules is
not easy with Haskell. Things that I found essential to write large
programs. I'm starting to think that the easiest way of writing generic and
reusable code with Haskell is writing a Haskell parser and code generator in
Haskell.
On Fri, May 27, 2011 at 3:00 PM, Daniel Fischer <
[email protected]> wrote:
> On Friday 27 May 2011 19:23:54, Federico Mastellone wrote:
> > Now I have a new problem, it's getting really difficult to program
> > generically and to create highly parameterized libraries.
>
> Yes.
>
> >
> > So far so good with type families, but when I want to return a generic
> > Set for the getValues function and provide a default implementation for
> > getValuesCount function I don't know how to do it, I don't even know if
> > it is possible.
>
> You can't return a generic Set in getValues (unless you jump through a lot
> of hoops, IntMultiMap has IntSets, so you'd have to transform those to
> Sets, ... yuck) and default implementations wouldn't be possible [or at
> least rather horrible], but
>
> >
> > newtype MultiMap k v = MultiMap (Map.Map k (Set.Set v))
> >
> > newtype IntMultiMap = IntMultiMap (IntMap.IntMap IntSet.IntSet)
>
> class (Ord (Elem c)) => Collection c where
> type Elem c
> emtpy :: c
> singleton :: Elem c -> c
> size :: c -> Int
> null :: c -> Bool
> member :: Elem c -> c -> Bool
> ...
>
> >
> > class MultiMapClass m where
>
> class (Collection (Coll m)) => MultiMapClass m where
>
> > type Key m
> > type Value m
>
> type Coll m
>
> > empty :: m
> > addValue :: Key m -> Value m -> m -> m
> > getValues :: Key m -> m -> Set (Value m)
>
> getValues :: Key m -> m -> Coll m
>
> > getValueCount :: Key m -> m -> Int
> > getValueCount k m = Set.size $ getValues k m
>
> getValueCount k m = size (getValues k m)
>
> Should work or be possible to make working.
> But things get more complicated the more generic functionality you want to
> add.
>
> It would probably be possible to get a more elegant implementation if you
> designed the library to use a class-based interface from the ground up
> (take a look at the edison library [EdisonAPI and EdisonCore on hackage]
> for an idea of how to structure the classes - edison is old, it was created
> long before type families or functional dependencies were available, I
> don't know what new stuff was incorporated into it, I suspect not too much,
> so you could probably improve the design with the new powerful tools at
> your hands, but as a source of inspiration, it should still serve well).
>
> The problem is that, as a rule of thumb, class based genericity costs
> performance. And the point of the containers package was to provide
> performant data structures, the genericity was wilfully forsaken.
>
> So, perhaps writing a generic envelope for the containers types might not
> be the best option. It could be better to start from a clean sheet.
> [disclaimer: I have not thought about how to do that, nor looked at the API
> or implementation from that point of view, so my hunch may be quite wrong.]
>
> Cheers,
> Daniel
>
>
--
Federico Mastellone
Computer Science Engineer - ITBA
".. there are two ways of constructing a software design: One way is to make
it so simple that there are obviously no deficiencies, and the other way is
to make it so complicated that there are no obvious deficiencies. The first
method is far more difficult."
Tony Hoare, 1980 ACM Turing Award Lecture.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110530/6804f439/attachment-0001.htm>
------------------------------
Message: 3
Date: Mon, 30 May 2011 15:07:09 -0500
From: Lawrence Bottorff <[email protected]>
Subject: [Haskell-beginners] Install on "foreign" server problems
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I'm trying to install the binary of 7.0.3 on a Bluehost.com server where I
have an account and ssh shell for a web client of mine. I want to eventually
run Yesod or happstack or some other sort of "haskell on the web." I've
talked with their tech support and they're cool with it as long as it's an
"in-place" install. Good. I try the ./configure and it errors saying things
like:
checking for path to top of build tree...
utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.9'
not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.7'
not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
configure: error: cannot determine current directory
I'm not (nor ever was) much of a sysadmin type. Any advice? I also installed
7.0.3 on my home machine and got a lot of dependency problems I'm sure I'll
face once I get past this GLIBC problem.
Actually, I'm just trying to do Web with Haskell on a server/cloud other
than my own home box. Again, I have a Web client and I'd like to get us off
PHP. Any Haskell-friendly clouds/hosts to suggest? Somebody said they had
Yesod running on Amazon EC2....
Olwe
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110530/28e3a81c/attachment-0001.htm>
------------------------------
Message: 4
Date: Mon, 30 May 2011 23:23:28 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Install on "foreign" server problems
To: Lawrence Bottorff <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On Mon, May 30, 2011 at 11:07 PM, Lawrence Bottorff
<[email protected]> wrote:
> I'm trying to install the binary of 7.0.3 on a Bluehost.com server where I
> have an account and ssh shell for a web client of mine. I want to eventually
> run Yesod or happstack or some other sort of "haskell on the web." I've
> talked with their tech support and they're cool with it as long as it's an
> "in-place" install. Good. I try the ./configure and it errors saying things
> like:
> checking for path to top of build tree...
> utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.9'
> not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
> utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.7'
> not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
> configure: error: cannot determine current directory
> I'm not (nor ever was) much of a sysadmin type. Any advice? I also installed
> 7.0.3 on my home machine and got a lot of dependency problems I'm sure I'll
> face once I get past this GLIBC problem.
> Actually, I'm just trying to do Web with Haskell on a server/cloud other
> than my own home box. Again, I have a Web client and I'd like to get us off
> PHP. Any Haskell-friendly clouds/hosts to suggest? Somebody said they had
> Yesod running on Amazon EC2....
> Olwe
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
Hi Lawrence
I think a lot of us are finding that the easiest solution is to
compile the binaries locally and upload to the server. In my case,
I've tried having the compiler on a VPS, but compiling is very
memory-intensive, and it can be a real pain whenever you need to
upgrade libraries.
My newest deployment is simply an EC2 micro instance running Ubuntu
32-bit, just like I have on my local system. I compile the app, copy
the binary and the static files, and deployment is done. I'll likely
be adding some notes about this to the Yesod book, and perhaps even
put together some scripts to automate the process more.
Michael
------------------------------
Message: 5
Date: Tue, 31 May 2011 00:01:35 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Install on "foreign" server problems
To: Lawrence Bottorff <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On Mon, May 30, 2011 at 11:53 PM, Lawrence Bottorff
<[email protected]> wrote:
>> Hi Lawrence
>>
>> I think a lot of us are finding that the easiest solution is to
>> compile the binaries locally and upload to the server. In my case,
>> I've tried having the compiler on a VPS, but compiling is very
>> memory-intensive, and it can be a real pain whenever you need to
>> upgrade libraries.
>>
>> My newest deployment is simply an EC2 micro instance running Ubuntu
>> 32-bit, just like I have on my local system. I compile the app, copy
>> the binary and the static files, and deployment is done. I'll likely
>> be adding some notes about this to the Yesod book, and perhaps even
>> put together some scripts to automate the process more.
>>
>> Michael
>
> So I would do an "in situ/in-place" binary install on a home machine and
> simply move that whole installation directory onto the foreign machine.
> Hmmm.... What about dependent libraries? If it can't find libc (or the
> GL-mesa libraries) won't it break? I'm guessing from the instructions that I
> would do a
> # ./configure --prefix=/home/me/haskell/
> then a
> # make in-place
> Is this right? Then move that /haskell directory onto the foreign box?
> Lb
>
What I meant was not to have GHC on the server at all. Build your web
apps locally, and then upload the binaries to the server. You can even
install a virtual machine locally with the same OS as what your server
is using.
Michael
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 35, Issue 60
*****************************************