On 8/13/07, David Roundy [EMAIL PROTECTED] wrote:
| Try executing:
|
| do { x - return 2; undefined; return (x*x); }
|
| in any monad you like
It's not just the identity monad:
Prelude :m +Control.Monad.State
Prelude Control.Monad.State flip evalState () $ do { x - return 2;
undefined;
Dan Piponi wrote:
| On 8/14/07, Lennart Augustsson [EMAIL PROTECTED] wrote:
| You don't normally call x::Int a computation of an Int because there's
| nothing that distinguishes the value of the x from what it was before
| you computed it.
|
| Can you spell out exactly what you mean by this?
After upgrading to haskell-platform-2010.1.0.0, with the improved unicode
support for IO in ghc-6.12, I hoped to be able to deal with filenames
containing non-ascii characters. This still seems problematic, though:
$ ls
m×n♯α
$ ghci
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Dear list,
For some time, I have maintained a small private module centred around the
following type of resource:
newtype Resource cap m = Resource { with :: forall a. (cap - m a) - m
a }
Interpretation: @Resource cap m@ is a resource, providing a capability
of type @cap@, which does
On Tue, 1 Jun 2010 21:10:40 +0200, Bas van Dijk v.dijk@gmail.com
wrote:
| [...]
| Hi Arie, I would love to see some examples of these resources for
| which you can't define a Resource[1] instance.
| [...]
|
| [1]
|
On Wed, Jun 2, 2010 at 2:28 PM, Bas van Dijk v.dijk@gmail.com
wrote:
Before answering your questions I would like to make sure I understand
your Resource type. When I want to create a memory Resource for
example is the following what you have in mind?
{-# LANGUAGE Rank2Types #-}
--
Hello Bryan,
On 2006-08-22, Bryan Burgers [EMAIL PROTECTED] wrote:
so, while this proposal is rather minor, i think that it is Good thing
I disagree. As a new learner to Haskell, I already have a hard time
keeping Constructors, Types, and Classes straight. I know what they
all are and what
Hello Brian and others,
On 2006-08-22, Brian Hulley [EMAIL PROTECTED] wrote:
I wouldn't like it because I'd like to eventually make the class namespace
separate from the tycon namespace so that I could write:
class Object a where
...
data Object = forall a. Object a =
Hello Brandon,
This could be handled with existential wrappers, except that the
wrapping is annoying, and probably interferes with optimizing when a
concrete type is known. Instead, a few changes to type synonyms handle
Bulat's cases.
With the proper interpretation, type synonyms like
Ashley Yakeley wrote:
Bertram Felgenhauer wrote:
This is correct according to the IEEE 754 standard, which defines
that NaN compares unequal to everything, including itself.
This is numerically useful, perhaps, but nonetheless disturbing. For it
would be helpful to expect that any type
David Roundy wrote:
Try
module Secret (Secret, classify, declassify)
where
data Secret a = Secret String a
classify :: String - a - Secret a
classify pw x = Secret pw x
declassify :: Secret a - String - Maybe a
declassify (Secret pw x) pw' | pw' == pw = Just x
declassify (Secret _ _) _ =
Hello,
Henning Thielemann wrote:
[...] I repeat my example of a source code formatting tool which must
decide whether to format
a +
b * c
or
a + b *
c
It needs to know the precedences of the used operators, which, as Brian
pointed out, is possibly not even defined
Nicolas Frisby wrote:
What if operator precedences were specified as a partial order instead
of using numbers?
Henning Thielemann wrote:
dict.leo.org says: great minds think alike
Funny, I thought of this too. It seems very natural.
You would probably want an implicit taking of transitive
Good evening,
Bulat Ziganshin wrote:
but when you want to have user-defined operators, that will mean that
you need either to define precedences to all other operators
(including those from other libs), or sometimes user programs will not
compile because they used combination of operators
Greg Buchholz wrote:
...That first article is the strangest. I couldn't reconcile the fact
that if our type signature specifies two arguments, we can pattern
match on three arguments in the function definition. Compare the number
of arguments in the first and second instances...
class
Greg Buchholz wrote:
I guess it just looks really strange to my eyes. For example, foo
and bar are legal, but baz isn't. That's what I was thinking of the
situation, but I guess the type classes iron out the differences.
Ah, but here 'baz' is illegal because of the (somewhat arbitrary)
David House wrote:
Also, it provides an infinite space for fixities. I think the problem
'binds tighter than X but not as tight as Y', where X and Y are only
fixity integer apart is somewhat common, and this would fix it. It
would allow for extensibility into the future, where the operator
Hi,
After a partial rewrite of my webserver, it is suffering from locked files:
/path/to/file: openBinaryFile: resource busy (file is locked)
The file in question really shouldn't be locked:
- Only my server knows of the file's existence.
- Only one thread accesses the file.
- The
Vyacheslav Akhmechet [EMAIL PROTECTED] wrote:
Are you using hGetContents? If you are, take a closer look at the
documentation. The function creates a lazy stream and until you finish
reading from it the file will be in the semi-closed state (which
means it will be locked).
No. I read/write
Ian Lynagh wrote:
Does anyone know what could cause this locking and/or how to prevent it?
Nothing else springs to mind. Are you able to send an example that shows
the problem? (obviously the smaller the example, the better).
I'll try to cut down the offending program to a workable size.
Hi Alex,
S. Alexander Jacobson wrote:
I guess I'm also not sure what belongs in a GADT and what belongs in a
typeclass e.g. here is an Arrow GADT
data Arrow b c where
Arr::(b-c) - Arrow b c
Compose::Arrow b c - Arrow c d - Arrow b d
First::Arrow a b - Arrow (a,c) (b,c)
Vyacheslav Akhmechet wrote:
Yes. I've run into similar issues with hs-plugins (albeit not the
same). What platform are you running on? How are you compiling your
code? Try compiling it with the -threaded flag and see if it fixes
your problem.
My platform is amd64 (x86_64). I usually compile
I'm loving learning Haskell quite a bit.
It is stretching my brain but in a delightfull way.
Great!
Using the cool lambdabot pointless utility I found out that:
\x - snd(x) - fst(x)
is the same as:
liftM2 (-) snd fst
Yes, the '(-) c' monad is very handy. One way to think about it is
[...] I think the concept of computer is better to
see as sort of telescope or translator. Computers
allow to look at processes (and complexity) which
would otherwise not conceivable to our limited minds.
The idea of computers as telescopes is from Daniel
Dennett though.
Computer Science is
Haskell is just too similar to Pascal.
This makes me wonder how people pronounce Pascal. It's probably because
I'm from Europe, but I put the stress on the second syllable. Pronouncing
it like rascal is, well, funny :-).
Greetings,
Arie
--
making someone not survive must surely count as
Hello,
Please view my claims with a healthy dose of scepticism: I know a little
category theory, but only from the mathematical point of view, not as
employed in computer science.
Scott Brickner wrote:
Anyway, as I understood it, the points were the terminal objects of
the category in which
Hi all,
Some time ago I reported a strange file locking problem. I have reduced my
offending program to a relatively small size.
This reduction process was quite entertaining. At one point, I could
reliably turn the locking off and on by removing and reintroducing a
certain unused import :s. I
Except that the example was not attached. Sorry.
Greetings,
Arie
min.tar.gz
Description: application/gzip
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Joel Reymont wrote:
May I ask why TH is easier to maintain than DrIFT?
I'm not familiar with DrIFT.
The reason is personal, and very silly. I only use ghc, so TH is available
automatically.
Like you, I have never used DrIFT, so I would have to get to know it, and
install it everywhere I want
Steve Downey wrote:
| OO, at least when done well, maps well to how people think. Things
| that can be directed to perform actions. There is also a well
| developed practice of OO analysis and design. It's not clear (at least
| to me) that there is an equivalent set of practices for functional
|
Pixel wrote:
i ended up with this one:
dwBool predicate l = (foldr combine (\_ - []) l) True
where
combine e fl beg = if beg predicate e
then fl True
else e : fl False
higher-order, like solutions 3 4, but simpler IMO :p
This
On Thu, 2 Sep 2010 19:30:17 +0200, Daniel Fischer
daniel.is.fisc...@web.de wrote:
Why would one consider using Ord for Map an abuse?
A kludge, for performance reasons, but an abuse?
Because it forces one to declare Ord instances for types which have no
natural ordering. It is useful to *not*
On Fri, 3 Sep 2010 12:02:22 +1000, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
What precisely do you mean by natural ordering?
An ordering that has relevant meaning for the information represented
by the datatype. Ideally, it should also be alone in being the order
anyone would expect
On Wed, 8 Sep 2010 05:51:22 -0700 (PDT), Kevin Jardine
kevinjard...@gmail.com wrote:
Ah, I was missing an important piece of the puzzle.
If I write:
class ToObj a where
toObj :: a - Obj
instance ToObj Obj where
toObj a = a
then
newtype Blog = Blog Obj deriving ToObj
On Sun, 03 Oct 2010 19:18:08 +0200, Ben Franksen
ben.frank...@online.de wrote:
How can I disable the standard arguments 'help' and 'version'?
If you're not fully committed to the cmdargs package, you might try my
package 'console-program' instead
On Thu, 14 Oct 2010 12:01:59 +0200, Michael Snoyman
mich...@snoyman.com wrote:
[...] which I believe is a flawed
design in the MonadCatchIO-transformers package. Here are my thoughts
on this and what I think needs to be done to fix it.
[...]
Try running the code with each version of go
Hi Pete,
Recently I read an interesting article by Peter Norvig[1] on how to
write a spelling corrector in 21-lines of Python. I wanted to try and
implement it in Haskell. My implementation is terribly slow and I was
hoping for some tips on how to improve it and make it idiomatic.
I had a
Hi Tomek!
In a CGI application I was gathering SQL statements I wanted to run in
the final transaction. Because I use haskelldb, it was most convenient
to use (Database - IO ()) as the type of the statement or a group of
statements. In this representation concatenating two statement groups
Dominic Steinitz wrote:
I suppose I could read my example as if there is anything that matches
Range BITSTRING _ _ then do the following and since nothing can ever
match it then it's a redundant case. But I would expect the compiler to
at least warn me that nothing can ever match this.
Why
You could also use 'compositional functional references'. These are
introduced in the paper A Functional Programming Technique for Forms in
Graphical User Interfaces by Sander Evers, Peter Achten and Jan Kuper.
=== Introduction ===
There are two things one typically wants to do when working with
Hello,
Stefan O'Rear wrote:
I've implemented this in Derive[1] in 12 minutes, counting the time
required to re-familiarize with the code. The patch is at [2] and has
also been darcs sent.
Neil Mitchell wrote:
It's been applied, and is now in the main repo.
Wow, that was fast. I didn't
David Menendez wrote:
| That's a neat idiom. I wonder how far one could usefully generalize it.
|
| For example,
|
| type Ref cx t = forall f. Functor f = (t - f t) - cx - f cx
|
| newtype Id a = Id { unId :: a }
| instance Functor Id where fmap f = Id . f . unId
|
| newtype K t a
As others have explained, you can't analyse your do-constructs, because
functions are opaque -- at the value level.
The canonical option would indeed seem to be to use arrows (or applicative
functors), instead of monads.
--
If you want to stick to monads, there is another possibility: carry
I wrote:
If you want to stick to monads, there is another possibility: carry around
the necessary checks *at the type level*. Below is a sketch of how you
could do this.
Importantly, the given code still requires you to specify the checks by
hand, when running the action; it only checks that
Hi,
What is the status of the MIME Strike Force?
The goals proposed at
http://www.haskell.org/haskellwiki/Libraries_and_tools/MIMEStrikeForce
promise a very useful library. Has the design been initiated?
Kind regards,
Arie
___
Haskell-Cafe mailing
Jeremy Shaw wrote:
What is the status of the MIME Strike Force?
Currently it is on hold while I work on some other higher priority
projects. But, I do hope to get back to it soon. (Or, perhaps someone
else will have time to work on it).
OK. Good to hear it is still alive, if slumbering.
I
Dave Bayer wrote:
[...] In the Haskell do expression, every line is equally special,
and type information is used to combine the lines, inserting implied
combinators.[...]
Desugaring do-notation is a syntactic transformation, requiring no type
information. (In practice, the parts may be
Dave Bayer wrote:
I've since done some experiments with Template Haskell, and I see
that Arie Peterson has suggested how you could proceed. However, are
you sure that you can't find a way to get this to work in vanilla
Haskell without extensions? Or, for that matter, are you sure there
isn't
Gregory Propf wrote:
Right, I read more about it and found this out. The 'main' function is
apparently magical at runtime and allows you to break the with pure
functionality just once but since it can call other functions this allows
for useful programs to be written.
There is more than one
Gregory Propf wrote:
As a programming exercise I'm trying to use the State monad to create a
simple parser. It's for a very simple assembly language for a simple
virtual machine. The state is a string of instructions. I want to be
able to call something like getNextInstruction to pull out
Gregory Propf wrote:
| [...] For example, am I to assume that I need to
| create my own instance of State and then define get and put for it?
No, there is a 'State s' monad provided (for arbitrary state type 's'),
which implements the 'get' and 'put' methods. In other words, 'State s' is
an
Alexis Hazell wrote:
| This may be a stupid question, but i don't understand how (indeed, if) one
| can
| maintain multiple states using the State monad, since 'get' etc. don't
| seem
| to require that one specify which particular copy of a State monad one
| wishes
| to 'get' from, 'put' to etc.?
Math alert: mild category theory.
Greg Meredith wrote:
But, along these lines i have been wondering for a while... the monad laws
present an alternative categorification of monoid. At least it's
alternative to monoidoid.
I wouldn't call monads categorifications of monoids, strictly speaking.
Im having difficulty to understand what phantom types are good for. Is
this just for improving runtime performance?
No. As the wiki says, you can use them to add static guarantees.
I read the wiki, and it says this is useful if you want to increase the
type-safety of your code, but the
On Sat, 14 Mar 2009 02:14:53 +0100 (CET), Henning Thielemann
lemm...@henning-thielemann.de wrote:
I think 'transformers' exports Control.Monad.Trans.State. This should not
conflict with MTL. However, MTL's State type is different from
transformer's one. Is that your problem?
No. The
Can anyone suggest a library written in Haskell which can solve equations of
the form xM(transpose(x)) = y, where x should be an integer vector, M is an
integer matrix and y is an integer? I'm aware that Mathematica can do this,
but I would like something written in Haskell. I haven't been
Hi,
I'm trying to use data kinds, and in particular promoted naturals, to simplify
an existing program.
The background is as follows: I have a big computation, that uses a certain
natural number 'd' throughout, which is computed from the input. Previously,
this number was present as a field
Hello Iavor,
One way to achieve the additional static checking is to use values of type
`Sing (n :: Nat)` in the places where you've used `Integer` (and
parameterize data structures by the `n`). If the code is fully polymorphic
in the `n`, then you can use it with values whose types as not
On Thursday 08 November 2012 17:15:49 Ertugrul Söylemez wrote:
| […]
| The idea is that reifyNum takes a polymorphic (!) function in 'n', such
| that the function can guarantee that it can handle any 'n', as long as
| it's an instance of ReflectNum. Now since the argument function is
|
On Friday 09 November 2012 17:53:54 Ertugrul Söylemez wrote:
I'm not sure if you're supposed to use the reflection library that way.
The idea is simply this:
reify :: a - (forall s. Reifies s a = Proxy s - r) - r
You pass in a value, any value you like actually ('reify' is fully
On Friday 09 November 2012 17:53:54 Ertugrul Söylemez wrote:
I'm not sure if you're supposed to use the reflection library that way.
The idea is simply this: […]
All right, I switched to this method, and it workes like a charm.
It is also more general than my attempt using data kinds, in the
Hi all,
The function 'block' and 'unblock' (from Control.Exception) have been
deprecated for some time, and are apparantly now being removed (in favour of
'mask').
Generalisations of these functions are (part of) the interface of
MonadCatchIO-transformers (the 'MonadCatchIO' class has
On Sunday 03 March 2013 17:07:18 Ertugrul Söylemez wrote:
Would anyone have a problem with a deprecation of
MonadCatchIO-transformers, and a failure to update it to work with a
base without 'block' and 'unblock'?
Yes. This is a simplified variant of a monad I use:
newtype Continue
On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote:
[…]
Would there be any interest in cleaning that up and adding it (or something
similar) to Control.Monad.CatchIO?
[…]
MonadCatchIO-transformers is being deprecated, as recently GHC has removed the
'block' and 'unblock' functions,
(Sorry for the long email.)
Summary: why does the attached program have non-constant memory use?
Introduction
I've written a program to do a big computation. Unfortunately, the computation
takes a very long time (expectedly), and the memory use increases slowly
(unexpectedly),
Hi Claude,
Looking at the heap profile graph (generated with +RTS -h, no need to
compile with profiling) I see the increasing memory use is split about
evenly between STACK and BLACKHOLE. I don't know what that means or why
it occurs, but replacing `small` solved that problem for me:
Hi Bertram,
Unfortunately, I don't know. I'll intersperse some remarks and
propose an alternative to stream fusion at the end, which allows
your test program to run in constant space.
A quicker way to spot the increased memory usage is to look at GC
statistics. I used
./Test +RTS
Hi Claude,
On Thursday 10 October 2013 20:05:37 I wrote:
Although, maybe I can do all the logic of the small function in the list
monad, and stream the resulting list, as you do in the above.
I tried a corresponding variant of my full program, but the memory use is
quite a lot higher at the
68 matches
Mail list logo