Jeremy Shaw wrote:
:
| However, I think this is buggy, because changes
| to 's' and 'w' will be lost if 'm' raises an
| exception.
:
That's determined by the way you stack your monad
transformers when declaring the type: adding error handling
to a writer monad, or adding writing to an error
David House wrote:
:
| You can fake this:
|
| (-!) = ($)
| (!-) = flip ($)
|
| foo -! liftM2 (,) !- bar
|
| Not perfect, but it's interesting nonetheless.
|
| And yes, this was a product of some #haskell
| brainstorming and algorithm tennis. :)
:-)
Was anyone in that brainstorm
Donald Bruce Stewart wrote:
[...]
While we're here we should fix:
chameneos
And anything else you want to take a
look at.
A community page has been set up to
which you can submit improved entries:
http://www.haskell.org/haskellwiki/Great_language_shootout
[...]
Well, then!
I've
Matthias Fischmann wrote:
Do you expect the contained type x to change during a
sequence of monadic actions? e.g. would you ever use
(=)
at the type 'Permutation Int - (Int - Permutation
Bool) -
Permutation Bool'?
no, i don't need that. but aside from
the fact that
data
Matthias Fischmann wrote:
another beginners question about monads: given the type
| data (Ix x) = Permutation x = Permutation [x]
i wanted to define
| instance Monad Permutation where
| return xs = Permutation xs
but of course nothing about the monad class guarantees xs
to be of
Joel Koerwer wrote:
Let's say I want to evaluate a function of type
(a-a-...-a-a), taking the arguments from a
list. If know the function ahead of time, I can
simply wrap it:
foo a b c d = ...
wrapFoo (a:b:c:d:_) = foo a b c d
But, as an exercise, I challenged myself to write
a function,
Seth Gordon wrote:
I thought I should check and see if anyone
on this list has used Haskell to munge a
ten-million-row database table, and if
there are any particular gotchas I should
watch out for.
Are you sure you want to target the data directly? Another
approach, that might have a
Vivian McPhail wrote:
...
I need the arg a to be evaluated before it gets
passed to a1 and a2. This definition does the right thing
when type 'a' is a function type, because it is not a
value, but with something like 'm a - (m a - m a) - m
a' with Forkable (a - b) the first arg gets evaluated
Hi Pete.
For such a small self-contained task, I don't think Haskell
is any better than Python.
Haskell would come into its own if you wanted some assurance
about type safety, and/or were taking on a task large enough
to warrant the use of records (and hence record update
notation).
Regards,
Vivian McPhail wrote:
class Forkable a where
fork :: String - a - a - a
What I would like to be able to do is
differentiate between Forkable (m a -
b) and Forkable (function type - b).
Have you tried this combination of instances?
instance Forkable (IO a) where ...
--
Brian Hulley wrote:
[EMAIL PROTECTED] wrote:
[...]
My reading of the semantics
(http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Weak.html#4)
is that you can be sure the proxy *object* is gone.
My problem is that I don't know what to make of the word
object in the
Magnus Jonsson wrote:
[...]
but your example fails on infinite lists
[...]
take 2 $ snd $ head $ splitStreams (map (\x - (0 ,x))
[1..])
Any approach, even sieving, will struggle with infinite
lists, won't it?
(take 2 . snd . head . splitStreams) [(i, i) | i -
[0..]]
Regards,
Tom
Brian Hulley wrote:
[...]
Ref.write proxiesRef $! (weakProxy : proxies)
(This is nothing to do with your main question, but the
strict application looks unnecessary there. Its right hand
side is already a constructor cell.)
[...]
In other words, if the entry for the proxy
in the
Andrea Rossato wrote:
Now I'm trying to create a statefull evaluator, with
output and
exception, but I'm facing a problem I seem not to be able
to
conceptually solve.
If a computation fails in your monad, do you still want to
return a value of the result type? I'd expect not, and
hence
Klaus Ostermann wrote:
[...]
data Exp e = Num Int | Add e e
data Labelled a = L String a
newtype Mu f = Mu (f (Mu f))
type SimpleExp = Mu Exp
type LabelledExp = Mu Labelled Exp
The SimpleExp definition works fine,
but the LabeledExp definition doesn't
because I would need something
Alexander Vodomerov wrote:
import Debug.Trace
main = do
putStrLn xxx
return (trace yyy ())
putStrLn zzz
only xxx and zzz is displayed. yyy is missing.
Why trace is not working?
Nothing uses the value of (trace yyy ()), so it is never
evaluated.
Try this instead, which uses the
Chad Scherrer wrote:
x = runST $ return 1
y = runST $ do {r - newSTRef 1; readSTRef r}
Neither of these works in ghci
x = runST (return 1)
y = runST (do {r - newSTRef 1; readSTRef r})
The escaping s is something to do with rank 2 polymorphism.
(Search for rank in the ghc user guide, for
Jared Updike wrote:
split is... unconcatIntersperse.
How about separate? (split or splitBy is better but
it is used
all over the place in many libs)
And for strings I definitely would use split :: [a] - [a]
- [[a]] a
lot, just like Python's split function. And words works
great for
dkarapet wrote:
I have been trying to understand closures
in haskell and how they relate
to side effects. I have been looking
around but all I find are trivial
examples with no side effects. Please let
me know if you know of any examples.
The side effects occur in the context that causes
Nils Anders Danielsson wrote:
A function like this has been suggested for the
standard libraries a couple of times before.
Someone suggested the name on, which I quite
like:
(*) `on` f = \x y - f x * f y
Thanks! I always wanted to be someone. :-)
Here's the link.
(In reply to
http://www.haskell.org/pipermail/haskell/2005-December/017109.html
)
One of the key things about those nested monads is that
*often* you
don't have to write things like
return $ throwError msg
but can simply write
throwError msg
because the nest has all the features of
Jerzy Karczmarczuk wrote:
:
| zeros fc sc = sc 0 zeros
|
| fails to compile as well. *I do not ask why, I know*.
|
| But I would like to continue this exercice along these
lines, without too much
| exotism (no monads, yet...), for my students. Do you have
any simple work-around?
|
Arjan van IJzendoorn wrote:
| Is there a shorter way to write the if-then-else part
below?
| if (cmdType cmd) /= (CmdSitError Server)
|then return $ Just seat_num
|else return Nothing
|
| return $ if cmdType cmd /= CmdSitError Serv
| then Just
23 matches
Mail list logo