While thinking about how to generate unique integer IDs on demand without using
a state variable, I came up with an interesting design pattern. It's a way of
doing side-effecting computation outside IO. Referential transparency is
preserved by making the side effects spatial rather than
Type synonyms aren't applied as I would expect during kind checking. What's
going on here?
type WithList a b = b [a]
type FooPair a b = (b, a - b)
-- error: `WithList' is applied to too many type arguments
ints1 :: WithList Int FooPair [Int]
ints1 = ([1], id)
-- error: `FooPair' is not
{-# OPTIONS_GHC -fglasgow-exts #-}
class Foo a b | a - b where
foo :: Foo b c = a - Maybe c
instance Foo String () where foo _ = Nothing
instance Foo Int String where foo 4 = Just (); foo _ = Nothing
There appears to be a type-safe way to use unsafeCoerce# for this:
import
I'd like to hear what tips and techniques you guys have for avoiding space
leaks. I understand the basic techniques to force evaluation of closures.
What I'd like to know is how you avoid space leaks in large, long-lived,
mutable data structures. These kind of data are particularly sensitive
_
FREE online classifieds from Windows Live Expo buy and sell with people
you know
http://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com?s_cid=Hotmail_tagline_12/06
I had a problem with strictness in the Parsec library, and I'd like to know
if there's a good way to solve it. The following illustrates the problem.
This raises an error when run:
main = parseTest (return undefined return 0)
Whereas this does not:
main = parseTest (return (Just
Hi folks,
I've been trying to compile a new ia64 port. I've cross-compiled an
unregisterised compiler that generated working binaries the first time it
was built, which was a pleasant experience. But I ran into issues with the
registerised build. The mangler is choking on floating-point
The (..) in the splice is out of scope according to GHC. If I use [||]
then it works, but for my purposes it's easier to use the constructors. How
should I refer to that variable?
import Data.Bits
import Language.Haskell.TH
main = print $ $(return $ VarE $ mkName ..) 7 (14 :: Int)
Here's a puzzle I haven't been able to solve. Is it possible to write the
initlast function?
There are functions init and last that take constant stack space and
traverse the list at most once. You can think of traversing the list as
deconstructing all the (:) [] constructors in list.
Ah, thanks for the replies. I like the approach that uses lazy tuples of
intermediate values because it has a recognizable similarity to the original
two functions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
This counterintuitive typechecking result came up when I wrote a wrapper
around runST. Is there some limitation of HM with respect to type checking
pattern matching?
data X a b = X (a - a)
run :: forall a. (forall b. X a b) - a - a
-- This definition doesn't pass the typechecker
run (X f) = f
11 matches
Mail list logo