ml
{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}
data Greet x = AlloAllo x x | AuRevoir deriving Show
newtype Fix f = In { out :: f (Fix f) }
deriving instance Show (f (Fix f)) => Show (Fix f)
Regards,
Reid Barton
___
H
ression "show (3 + 4)" must be in a module for this
demonstration.)
There is no provision for extending the defaulting mechanism to your
own type classes. Arguably this is a good thing, since defaulting can
sometimes behave surprisingly already under GHCi's rules, as anyone
who
s.blogspot.com/2010/03/bruno-oliveira-and-i-are-working-on.html
(click the link "draft")
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
ecent release on Hackage.
http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.html
http://hackage.haskell.org/package/MagicHaskeller
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
ere
push :: b -> a -> a
? The second one might help you with your subsequent problem
(although I didn't understand quite what you were trying to do there).
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
ot;, and then run
ghc -e "forM [[1,2,3]] reverse" imports.hs
I use this method in a short shell script "interact" so that I can
apply Haskell functions to files from the command line and don't have
to type the full qualified na
; (String, String)`.
In Haskell, these just don't unify because there are no type-level lambdas.
Even if there were, how is the typechecker supposed to know that we want
the solution `m a = String -> (a, String)` and not `m a = a -> (a, a)`
or many other possibilites?
The purpose of th
M -> E M
type Expr = E M
type AExpr = E Blah
-- The same simplify function we would write for the original Expr,
-- with a different type
simplify :: E a -> E a
simplify (Const x) = Const x
simplify (Add (simplify -> a) (simplify -> b)) = case (a, b) of
(Const 0, _) -> b
(_, Const 0) -> a
_ -> Add a b
simplify (Mul (simplify -> a) (simplify -> b)) = case (a, b) of
(Const 1, _) -> b
(_, Const 1) -> a
_ -> Mul a b
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
hand B
could export TH descriptions of multiple instance corresponding to
different versions of A.Foo, relying on the importer to select the one
which matches its selected version of A.
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
ling for "opposite
monoid" and "dual monoid" to see the standard usage for yourself.
There is no standard meaning for the phrase "dual monoid", but I would
venture that it is never used to mean "opposite monoid" in the
mathematical literature.
(Sorry for the r
This problem is solved! Especially in the upcoming GHC 6.12.1! Just
use UTF-8 everywhere!
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
m?
Her editor probably saved the file in a text encoding other than
UTF-8, such as ISO-8859-1. By definition a Haskell program is a
Unicode text document. runhaskell is encountering an invalid UTF-8
sequence E7 61 while decoding your program file.
The other responses will be relevant to
an exercise, tracing the evaluation of memoized_fib
using each of these desugarings, and then trying them out in ghci.
Then you'll be able to tell which desugaring ghc is using. (It's not
the one used in the Report! In principle this is a bug since we can
distinguish them using seq.)
Reg
skell.org/pipermail/haskell-cafe/2009-June/062452.html
If you prefer to use EmptyDataDecls, you can replace the first four
lines by
data Z
data S n
data Id :: * -> *
data (:.) :: (* -> *) -> (* -> *) -> (* -> *)
And I still don
On Sun, Oct 11, 2009 at 08:17:48PM -0400, Reid Barton wrote:
> It seems that the definition of split in System.Random is not really
> satisfactory.
For the curious, the reason for the asymmetry between fst . split and
snd . split is that the RNG states produced by mkStdGen have varying
t
sequences. Now let's look at the left side:
GHCi> length $ nub [ take 30 . map (fst . random) . iterate (fst . split) $
mkStdGen i :: [Bool] | i <- take 1 . randoms $ mkStdGen 0 ]
8
This doesn't seem good.
Michael's code (below) is effectively doing iterate (fst . split
On Sat, Sep 05, 2009 at 02:52:50AM -0700, staafmeister wrote:
> How would experienced haskellers solve this problem?
You could just memoize using an array, like in C.
import Data.Array
occurrences :: Num a => String -> String -> a
occurrences key buf = grid ! (0, 0) -- grid ! (i, j) = occurrenc
On Wed, Jun 17, 2009 at 02:28:55AM +0200, Gü?nther Schmidt wrote:
> Hi guys,
>
> I'd like to generate an infinite list, like
>
> ["a", "b", "c" .. "z", "aa", "ab", "ac" .. "az", "ba", "bb", "bc" ..
> "bz", "ca" ...]
I'm surprised everyone is giving clever recursive solutions rather than
concatM
On Fri, Jun 05, 2009 at 01:58:33PM -0700, Ryan Ingram wrote:
> I tried several different implementations for Times but I was unable
> to come up with one that passed the type family termination checker.
> Is there a way to do so?
Here is a solution. I don't understand exactly why this works while
On Sun, Feb 15, 2009 at 09:59:28PM -, Sittampalam, Ganesh wrote:
> > Stateful-mtl provides an ST monad transformer,
>
> Is this safe? e.g. does it work correctly on [], Maybe etc?
>
> If not this should be flagged very prominently in the documentation.
It is not safe: it has the same proble
On Mon, Feb 02, 2009 at 02:41:36PM -0800, Dan Piponi wrote:
> 2009/2/2 Luke Palmer :
>
> > But Nat ~> Bool is computably uncountable, meaning there is no injective
> > (surjective?)
> > function Nat ~> (Nat ~> Bool), by the diagonal argument above.
>
> Given that the Haskell functions Nat -> Boo
On Thu, Oct 16, 2008 at 12:57:05PM -0700, Simon Michael wrote:
>> Basically it has a more accurate haskell parser, and it has a simpler
>> way of cycling through possible indentations: TAB moves to the right
>> and BACKSPACE to the left.
>
> Unfortunately, it can sometimes fail to parse what's i
he author of ListT has not forgotten to
write a MonadPlus instance).
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
hich error*
should you return if there's more than one Left? Do you really want
to check whether every run s1 y is a (Right whatever)? In that case
you are not gaining much from the laziness of ResultSet and might as
well use ResultSet'. Until you decide the answer to questions
nce for n. Then you
can write join :: m (n (m (n a))) -> m (n a) as
m (n (m (n a))) --- fmap sequence ---> m (m (n (n a)))
-- join -> m (n (n a))
-- join -> m (n a).
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
ctors at different index in unique
> array later.
Then once you've finished constructing the list, turn it into an array
with listArray and use random access into that.
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http:
Nothing -> return []
xs <- go
print xs
The unsafeInterleaveIO is now hidden inside getChanContents. (I have
an outMVar rather than an outChan just in case accumulator could
produce lots of output before consuming much of its input.)
Regards,
Reid Barton
___
e to break with a similar message, since I have a
32-bit system. If I delete utils/pwd/pwd, the configure script
automatically rebuilds it and then completes successfully.
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
*** [install] Error 1
Have I got some of the steps wrong?
Regards,
Reid Barton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
29 matches
Mail list logo