On Tue, Apr 7, 2009 at 6:11 PM, Brad Larsen wrote:
> prop_insert_idempotent :: (Eq d, PrefixDict d) => d -> Word -> Bool
> prop_insert_idempotent d w = insert w d' == d'
> where d' = insert w d
>
> The problem is this: I can't think of a non-kludged way of checking that
> TrieDict and Lis
On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry wrote:
> As I understand it, the type checker's thought process should be along
> these lines:
>
> 1) the type signature dictates that x has type Memo d a.
> 2) appl has type Memo d1 a -> d1 -> a for some d1.
> 3) we apply appl to x, so Memo d1 a = Memo
The prefix notation for
> \a b c -> (a,b,c)
is (,,)
Without the parentheses, it's not immediately clear whether
> foo $ a,b
means
> foo (a,b)
or
> foo (\c -> (a,b,c))
or some other, bigger tuple size.
Anyways, it's just syntax :)
-- ryan
On Mon, Apr 6, 2009 at 9:08 AM, Daniel Fischer wrote:
ourse that this use is feasible at all.
>
> Hi Günther,
>
> a couple of weeks ago I was looking into Zippers my self as well.
> After reading all the documents mentioned in the other messages, I
> decided to go for my implementation as the proposed ones seemed to me
> unnecessarily compli
2009/3/30 michael rice :
> I'm still not sure what some of the error messages I was getting were about.
> As I wrote the function I tried to be aware of what "mixed mode" operations
> were kosher ala
This is a mistake, but understandable given your lispy background;
there aren't really "mixed mode
Take a look at Data.Accessor on hackage:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor-template
-- ryan
On Sun, Mar 29, 2009 at 2:13 AM, Andrew Coppin
wrote:
> Haskell's record syntax is quite
Just use "/" for division. % is for construction of rationals from
the "underlying" numeric type.
For example, instead of "toRational x" you can write "x % 1".
-- ryan
2009/3/28 michael rice :
> I may be missing something here, but this is what I intended.
>
> An expression of the form
>
>
On Wed, Mar 25, 2009 at 8:25 AM, Jonathan Cast
wrote:
> On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote:
>> the ordering that the state monad expects
>> (and I can never remember which way around they are in Control.Monad.State).
>
> Really? I found it obvious once I figured out it how simp
Given the Y combinator, Y (\x.x) has no normal form.
However, (\a. (\x. x)) (Y (\x. x)) does have a normal form; (\x. x).
But it only reduces to that normal form if you reduce the (\a. ...)
redex, not if you reduce its argument. So depending on evaluation
order you might not reach a normal form.
On Fri, Mar 20, 2009 at 1:01 AM, Dan Doel wrote:
> However, to answer Luke's wonder, I don't think fixAbove always finds fixed
> points, even when its preconditions are met. Consider:
>
> f [] = []
> f (x:xs) = x:x:xs
>
> twos = 2:twos
How about
> fixAbove f x = x `lub` fixAbove f (f x)
On Wed, Mar 18, 2009 at 8:10 AM, David Menendez wrote:
> l_out :: Functor f => Lfix f -> f (Lfix f)
> l_out = cata (fmap l_in)
>
> g_in :: Functor f => f (Gfix f) -> Gfix f
> g_in = ana (fmap g_out)
OK, I understand these now.
But they both seem to have significant performance implications, whic
On Wed, Mar 18, 2009 at 8:10 AM, David Menendez wrote:
> l_out :: Functor f => Lfix f -> f (Lfix f)
> l_out = cata (fmap l_in)
>
> g_in :: Functor f => f (Gfix f) -> Gfix f
> g_in = ana (fmap g_out)
Well, you just blew my mind. I had an informal proof in my head of
why g_in shouldn't be possible
One typo correction:
On Wed, Mar 18, 2009 at 2:15 AM, Ryan Ingram wrote:
> Let "Pair a b" be an abbreviation for "forall c. (a -> b -> c)",
This should say that Pair a b is an abbreviation for
forall c. (a -> b -> c) -> c
-- ryan
_
On Tue, Mar 17, 2009 at 4:36 PM, ben wrote:
> Then I stumbled over a blog entry of Shin-Cheng Mu [2] and from there
> over an article of Wadler [3], where the least fixpoint is encoded as
>
> Lfix X. F X = All X. (F X -> X) -> X.
>
> and the greatest fixpoint as
>
> Gfix X. F X = Exists X. (X
On Tue, Mar 17, 2009 at 10:30 AM, Brent Yorgey wrote:
> I don't understand your classes Eq1, Eq2, and Eq3. How would you make
> an instance of Eq1 for, say, [] ?
You don't.
> It seems you are confusing _value_ equality with _type_ equality? A
> value of type a :=: a' is a proof that a and a' a
Having the state be an instance of Typeable breaks the purity
guarantees of runST; a reference could escape runST:
let v = runST (V `liftM` newSTRef 0)
in runST (readSTRef $ fromJust $ getValue v)
Keep in mind that the state actually used by runST is "RealWorld";
runST is just a pretty name f
On Mon, Mar 16, 2009 at 7:55 AM, Jake McArthur wrote:
> I think it depends on what we want to take "unsafe" to mean. In my
> opinion, the word "unsafe" should really only be used in cases where
> using the function can case an otherwise well-typed program to not be
> well-typed. I'm pretty sure I
On Sun, Mar 15, 2009 at 1:56 PM, Jonathan Cast
wrote:
>> But not if you switch the (x <- ...) and (y <- ...) parts:
>>
>> main = do
>> r <- newIORef 0
>> v <- unsafeInterleaveIO $ do
>> writeIORef r 1
>> return 1
>> y <- readIORef r
>> x <- case f v of
>>
unsafeInterleaveIO allows embedding side effects into a pure
computation. This means you can potentially observe if some pure
value has been evaluated or not; the result of your code could change
depending how lazy/strict it is, which is very hard to predict!
For example:
> -- given
> f :: Inte
For the second case you might be able to come up with a commutative
hash-combiner function for && and ||.
For the lambda-term situation, I can think of a couple ways to hash
that give what you want.
(1) Ignore variable names altogether while hashing; this gives you
what you want but has the disad
2009/3/12 R J :
> Part of my problem is that "e" is defined as a function that takes
> one argument, I don't see how that fits in with the usual scheme for foldr,
> which, as I understand it, is:
>
> foldr f e [x1, x2, ...] = f x1 (f x2 (f x3 ...(f xn e)))...
It's pretty easy, actually. Lets rewr
2009/3/11 R J :
> 3. Any advice on how, aside from tons of practice, to develop the intuition
> for rapidly seeing solutions to questions like these would be much
> appreciated. The difficulty a newbie faces in answering seemingly simple
> questions like these is quite discouraging.
Don't be dis
I really like this book:
http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/
It walks you through building a compiler to a reasonable intermediate
language, which you can then start with; it's is a much easier problem
to convert that intermediate langauge to assembly, C,
So, by using the Haskell interpreter, you're using the
not-very-well-supported dynamically-typed subset of Haskell. You can
tell this from the type signature of "interpret":
> interpret :: Typeable a => String -> a -> Interpreter a
> as :: Typeable a => a
> as = undefined
(from
http://hackage.
On Wed, Mar 4, 2009 at 12:53 PM, Cristiano Paris wrote:
> I'd (and indeed I did) write 'update' as:
>
> update z x = z { this = this z >> Just x }
>
> exploiting the '>>' operator's logic. How would this differ from the
> corresponding 'update' in the original Huet's FP? Maybe I don't get
> how my
2009/3/4 R J :
> What's the pure solution that uses cases and recursion on
> CatList, not Haskell's built-in lists, to capture the equality of nested
> CatLists?
As Rafael pointed out, the simplest thing to do is to convert to a
canonical form; you can prove that each CatList has a single canonica
I've found DiffArrays to be way too slow/memory-hogging for real usage.
Since you are in IO already (StateT s IO), you'll probably be better
off using a mutable array for a data structure.
Some things are still best done in the imperative style. You can be a
bit safer by using ST as the bottom m
:27 PM, David Menendez wrote:
> On Fri, Feb 27, 2009 at 1:28 PM, Ryan Ingram wrote:
>> Then it comes down to, within a session, is there some way for an
>> STTRef to "mingle" and break the type-safety rule. I can think of two
>> potential ways this might happen. First
something like Cont, there may be a way for an
STTRef to get transmitted "back in time" via a continuation to a point
where it hadn't been allocated yet.
So if there is a counterexample I expect it to come down to one of
those two cases.
-- ryan
On Thu, Feb 26, 2009 at 11:22
Try starting with
(m * n) / m = n -- given m /= 0
Then do case analysis on n.
I found this process quite enlightening, thanks for posting.
-- ryan
2009/2/24 Peter Hilal :
> I'm working my way through Bird's _Introduction to Functional Programming
> Using Haskell_. I'd appreciate any help
On Fri, Feb 20, 2009 at 11:33 AM, Kim-Ee Yeoh wrote:
> Here's a counterexample, regardless of whether you're using
> constructive or classical logic, that (forall a. T[a]) -> T' does
> not imply exists a. (T[a] -> T').
>
> Let a not exist, but T' true. Done.
That isn't quite a proper counterexamp
- but I suppose that since mutable
>> references are really equivalent to single-threadedness where referential
>> transparency is concerned, that could be pulled off -- I would still want a
>> StateThread associated type, but that'd just be RealWorld for IO and STM, I
>> gu
So, why not use this definition? Is there something special about ST
you are trying to preserve?
-- minimal complete definition:
-- Ref, newRef, and either modifyRef or both readRef and writeRef.
class Monad m => MonadRef m where
type Ref m :: * -> *
newRef :: a -> m (Ref m a)
readRef
On Wed, Feb 18, 2009 at 2:12 AM, Lennart Augustsson
wrote:
> Also, if you are using ghc you can turn on the extension that allows
> undecidable instances and make the type system Turing complete.
And you get the additional pain of a potentially nonterminating
compiler without any of the nice type
On Tue, Feb 17, 2009 at 5:22 AM, Dan Doel wrote:
> -- fail: inferred type less polymorphic than expected
> -- This seems like it could perhaps work, since E''
> -- re-hides the 'a' but it doesn't, probably because there's
> -- no way to type the enclosed lambda expression properly.
> -- You'd prob
C-- is kind of dead; it lives on in spirit as a data type used by the
back end of GHC, but there hasn't been much development in C-- as a
language proper in a while.
LLVM seems to be gaining momentum in that space; Lennart has been
posting some experiments with generating LLVM code in Haskell in h
Don't use the
> data (context) => type = constructors
syntax, it doesn't do what you want.
All it does is add the context to the constructor B while not
providing it to any of the functions that use it.
A better solution is
> data Bar a = forall b. Foo a b => B a b
or, equivalently, using GADT
You can roll your own pure STT monad, at the cost of performance:
-- Do not export any of these constructors, just the types STT and STTRef.
data W = forall a. W !a
data Heap s = Heap !Int !(IntMap W)
newtype STT s m a = STT (StateT (Heap s) m a) deriving (Monad,
MonadTrans, MonadIO, insert other
On Sun, Feb 15, 2009 at 11:50 AM, Kim-Ee Yeoh wrote:
> Having said that, I'm not sure about the statement on page 9
> that "readVar v simply does not have type forall s. ST s Bool."
> The variable v could be of type "forall s. MutVar s Bool",
> in which case all of "runST (readVar v)" typechecks.
2009/2/13 Peter Verswyvelen :
> No the error I got was
> Could not deduce (Controller m v c)
> from the context (Controller m v c2)
> arising from a use of `MVC' at NM8\GUI\PanZoom.hs:126:32-65
> Possible fix:
> add (Controller m v c) to the context of the constructor `MVC'
> In
You can do this with another type class.
class (Chunkable c1 el1, Chunkable c2 el2) => ChunkMap c1 el1 c2 el2 where
cMap :: (el1 -> el2) -> c1 -> c2
instance ChunkMap [a] a [b] b where cMap = map
If you want to assert that c1 and c2 are really related, you can add
functional dependencies to
On Mon, Feb 2, 2009 at 3:55 PM, Benedikt Huber wrote:
> f is 'easy to implement' if it enumerates all functions, not just total
> ones. Otherwise, f is hard to implement ;)
>
> In the first case, if we have (f n n) = _|_, then g n = not (f n n) = _|_ as
> well, so the diagonalization argument does
2009/2/2 Luke Palmer :
> However! If we have a function f : Nat -> Nat -> Bool, we can construct the
> diagonalization g : Nat -> Bool as: g n = not (f n n), with g not in the
> range of f. That makes Nat -> Bool "computably uncountable".
This is making my head explode. How is g not in the ran
That code is in /rts/STM.c
-- ryan
2009/1/30 Daryoush Mehrtash :
> I like to look at the code where the runtime detects a TVar, inside an
> atomic block, has been changed by another thread and hence it aborts the
> atomic operation. Any suggestion as to where I would find the code?
>
> daryou
1) yes, but that's sumAA's fault, not the data structure; sumAA isn't
tail recursive so it has to build a much bigger stack:
x + (y + (z + (...)))
whereas it could run in constant space if it did this instead:
(...((x + y) + z) + ...)
Usually this transformation is done by passing an accumulato
On Thu, Jan 29, 2009 at 12:44 AM, Eugene Kirpichov wrote:
> With the Y combinator, the code becomes as follows:
>
> f = \somedata1 somedata2 -> fst $ fix (\(aa,bb) -> (AA somedata1 bb,
> BB somedata2 aa))
>
> I tried to prove to myself that the structure really turns out cyclic,
> but games with r
2009/1/27 Matthijs Kooijman :
> Hi all,
>
> I've been reading the gentle introduction to Haskell a bit more closely today
> and there a few things which I can't quite understand (presumably because they
> are typo's). I've found two issues with the "Using monads" section [1]. Not
> sure if this is
flaw in your logic, but it's
> not true of my usage. Your definition always produces a non-null list. The
> particular g in my mind will eventually produce a null list, somewhere down
> the line. I think if that's true, we can guarantee termination.
>
> On Sat, Jan 24, 200
foldr f z xs =
x0 `f` (x1 `f` (x2 `f` ... (xN `f` z) ...))
In particular, note that if f is a total function, xs is finite and
totally defined, and z is totally defined, then the result of this
fold is totally defined.
Now consider your "f" (rewritten slightly)
f x xs
| null xs = []
| p
2009/1/24 Olex P :
> What I want to ask you guys can we define a function with arbitrary number
> of parameters? Actually not really arbitrary but just several possibilities
> (as we have with value constructors).
> For instance cross product can have 1, 2 or 3 vectors as inputs depends on
> the di
On Fri, Jan 23, 2009 at 10:49 PM, Thomas Davie wrote:
> Isn't the point of bottom that it's the least defined value. Someone above
> made the assertion that for left identity to hold, _|_ `mappend` () must be
> _|_. But, as there is only one value in the Unit type, all values we have
> no inform
oundness.
>
> But we have not yet implemented the idea yet. First priority is to get type
> families working properly, and in conjunction with type classes. Then we can
> move on to adding features.
>
> Simon
>
> | -Original Message-
> | From: haskell-cafe-bou
I think it's possible, but not in a very clean way.
First lets look at ap:
> ap mf mx = do
> f <- mf
> x <- mx
> return (f x)
equivalently, desugared:
> ap mf mx = mf >>= \f -> mx >>= \x -> return (f x)
So, it's possible to make a definition of >>= where "ap" works as you like:
>Z (
I recommend checking out Don Syme's slides from CUFP 2008.
http://cufp.galois.com/2008/slides/
This isn't Haskell directly, it's F#, but it fits the "functional
programming generally", and the two languages have, relative to the
universe of programming languages, more in common than they do
diffe
What's the status of overlapping/closed type families? I'm interested
in something like the following, which can currently be implemented in
GHC with Oleg-magic using functional dependencies, but cannot, to my
knowledge, be implemented with type families:
data HTrue = HTrue
data HFalse = HFalse
ilator op ann x y =
> assuming (x == ann) ann `unamb`
> assuming (y == ann) ann `unamb`
> (x `op` y)
>
> [1] http://haskell.org/haskellwiki/Unamb
> [2]
> http://hackage.haskell.org/packages/archive/unamb/latest/doc/html/Data-Unamb.html
> [3] http://conal.
On Mon, Jan 19, 2009 at 9:10 AM, ChrisK wrote:
> Consider that the order of pattern matching can matter as well, the simplest
> common case being zip:
>
> zip xs [] = []
> zip [] ys = []
> zip (x:xs) (y:ys) = (x,y) : zip xs ys
If you are obsessive about least-strictness and performance isn't a
gi
On Sun, Jan 18, 2009 at 12:43 PM, sam lee wrote:
> The following code compiles fine on my ghci
This seems like a bug, you didn't enable overlapping instances and
these two instances clearly overlap:
>instance Sexpable String where
>instance Sexpable a => Sexpable [ a ] where
since Strin
On Sun, Jan 18, 2009 at 11:23 AM, Brian Hurt wrote:
> instance Sexpable String where
> instance Sexpable a => Sexpable [ a ] where
> Note that I am not implementing Sexpable Char anywhere, so the only valid
> transform for [Char] should be the String one. But this still causes a
> compiler erro
On Sun, Jan 18, 2009 at 3:23 AM, Andrew Coppin
wrote:
> Given that liftM exists, why is having an identical implementation for fmap
> useful?
For many structures, it's easier to define (>>=) in terms of fmap and
join. For these objects, often the "generic" implementation of liftM
is far less eff
Here's the desugaring:
> do { pattern <- expression ; rest }
desugars to
> expression >>= \temp -> case temp of
>pattern -> do { rest }
>_ -> fail "Pattern match failure"
(where "temp" is a fresh variable not used elsewhere, and the failure
message usually includes source position)
Whe
Here's a series of refactorings that I feel gets to the essence of the code.
For reference, here's the original.
> add :: JSON a => MyData -> String -> a -> MyData
> add m k v = fromJust $ (return $ json m) >>= jsObj >>= (return .
> fromJSObject) >>= (return . ((k, showJSON v):)) >>= (return .
>
I suggest you start using "let" in your do blocks; both of these
problems are solvable with let.
Binding with <- instead of "let" makes the type system work harder,
and will generally require type annotations & extensions for
polymorphic results. And it's almost never what you want, anyways;
you
At ICFP this year there was a fun presentation about this subject.
The paper & library are available from:
http://www.cs.chalmers.se/~russo/seclib.htm
-- ryan
2009/1/13 Daryoush Mehrtash :
> I am trying to figure out a clean way to add authentication and
> authorization in a webservice. The
> -- I'm not entirely sure on this one, because type witnesses confuse me.
> compare_changes_with_old :: (Patchy p) =>
> FL p C(x y)
> -> FL p C(x y)
> -> (FL p :> FL p) C(x y)
>
> C(args...) is a preprocessor macro that expands to args if Darcs is
>
Some questions first:
What's the type of this function supposed to be?
What's the type of unsafeCompare?
How is the data type with NilFL and :>: defined?
-- ryan
On Mon, Jan 12, 2009 at 5:43 AM, Rob Hoelz wrote:
> Forwarding to Haskell Cafe per Eric's suggestion.
>
> Begin forwarded message:
>
>From your blog post:
> Another solution is to use type synonyms to flip the parameter order
> around and write
>
> > type StateT' m s a = StateT s m a
>
> That in combination with the TypeSynonymInstances extension would
> allow us to write instance MonadState (StateT' m),
This isn't true, actual
No, but you can do this:
> {-# LANGUAGE GeneralizedNewtypeDeriving #-}
> import Control.Monad (liftM)
> newtype Functorize m a = F { unF :: m a } deriving (Eq, Show, Monad)
Insert any other type classes you care about potentially inheriting
from the parent Monad into the deriving clause, like Mo
I like using smart constructors to replace :<=>: and :=>:
a \/ b = a :\/: b
a /\ b = a :/\: b
a ==> b = Not a \/ b
a <=> b = (a ==> b) /\ (b ==> a)
Also, if you generalize Sentence a bit you get a really nice
formulation of "true". See my paste at http://hpaste.org/13807#a2
-- ryan
2009/1/10
My issue is that there seem to be many cases where the syntax
extension does *almost* what I want, but not quite. And there isn't
any method to extend it, so you are left with two choices:
(1) Go back to unsugared syntax
(2) Hack your technique into the constraints of the existing syntax exten
I seem to recall reading somewhere that an object's StableName can
change when it becomes evaluated; so it's possible you aren't
detecting sharing because of this.
You might try this instead:
> mkStableName' a = mkStableName $! a
This forces the object to become evaluated before calling mkStable
You can't safely convert an IOUArray into a Ptr; Ptr is a raw value
which isn't noticed by the garbage collector, so if the data is
relocated or GC'd while you have a pointer to it, further access will
corrupt memory. Rather, the data inside of an IOUArray is held in a
MutableByteArray#.
In Data.
Hi Phil. First a quick style comment, then I'll get to the meat of
your question.
getRanq1 is correct; although quite verbose. A simpler definition is this:
getRanq1 = State ranq1
This uses the State constructor from Control.Monad.State:
State :: (s -> (a,s)) -> State s a
What it sounds like y
On Wed, Jan 7, 2009 at 12:58 PM, Jeff Heard wrote:
> And how do I encode
>
> a{ mousePositionf = b }
>
> in template haskell without using the [| |] syntax, so that I can use mkName?
Whenever I have a question like that, I just ask ghci:
$ ghci -fth
ghci> :m Control.Monad.Identity Language.Haske
I've been fighting this same problem for a while. The solution I've
come up with is to encode the axioms into a typeclass which gives you
a proof of the axioms.
Here's an excerpt from some code I've been playing around with; HaskTy
and Lift are type families.
-- Theorem: for all t instance of Li
2008/12/31 Paolino :
> I must ask why runWriterT k :: State s (a,[Int]) is working.
> Looks like I could runIO the same way I evalState there.
> In that case I wouldn't wait for the State s action to finish.
>
> Thanks
Assuming you have Control.Monad.State.Lazy (which I think is the
default), here
Also, it's actually really hard to tie the knot in the update; without
some kind of distinguished node that allows you to know that it is the
beginning/end of the list.
For example, in this DList:
1,1,1, lots of times, 1, 2, 1, 1, ... lots of times, 1, (loop)
If you change the 3rd "1", how
IO is not lazy; you never make it to "print".
Consider this program:
> k = f 0 where
>f n = do
>lift (print n)
>tell [n]
>f (n+1)
> weird :: IO [Int]
> weird = do
> (_, ns) <- runWriterT k
> return (take 20 ns)
What should "weird" print? According to "k", it
On Mon, Dec 29, 2008 at 4:29 AM, wrote:
> Would you please give me a complete example of code that I could have more
> information
> on the idea?
Sure, I put up an example at http://ryani.freeshell.org/haskell/gmap.hs
class MapKey k where
data (:->) k :: * -> *
newMap :: (k -> v) -> (k
On Mon, Dec 29, 2008 at 7:56 AM, Evan Laforge wrote:
> But I thought a haskell RTS was a win for correctness and ease of
> modification, but a lose for performance? Thanks for the paper link,
> I'll check it out in a bit. There's a seemingly endless supply of
> interesting haskell papers out the
Bonus points if you find the stupid bug in my code :)
-- ryan
On Mon, Dec 29, 2008 at 1:48 AM, Ryan Ingram wrote:
> On Sun, Dec 28, 2008 at 10:13 PM, David Menendez wrote:
>> 2008/12/29 Raeck chiu :
>>> It seems to be very difficult to change the number of Male or Female
On Sun, Dec 28, 2008 at 10:13 PM, David Menendez wrote:
> 2008/12/29 Raeck chiu :
>> It seems to be very difficult to change the number of Male or Female if a
>> concrete data structure is not used. Is it possible change the number of
>> Male in classA
>> when represent classA using function?
>
>
2008/12/28 Luke Palmer :
> Adaptive programming is sortof the opposite of reactive programming, the way
> I see it. Adaptive is imperative (that's the best word I have for it), i.e.
> you have a bunch of variables and your code decides which one to change.
> Whereas reactive programming, at the ve
On Sun, Dec 28, 2008 at 11:08 PM, Evan Laforge wrote:
> But every STM operation has to modify a transaction log, which seems
> like it should be even more expensive than frobbing a lock bit. So it
> seems like if the per-operation STM overhead is higher, and blocking
> contention is the same (ass
Both readTVar and writeTVar are worse than O(1); they have to look up
the TVar in the transaction log to see if you have made local changes
to it.
Right now it looks like that operation is O(n) where n is the number
of TVars accessed by a transaction, so your big transaction which is
just accessin
See "Adaptive Functional Programming" by Acar et al.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.61.2257
Doesn't talk about OO specifically, but rather how to make "updatable"
computations in a mutable language.
There's a Haskell implementation, too.
http://hackage.haskell.org/cgi-bin
ons:
> evalAF :: Applicative f => AF f x () a -> (f x, a)
> evalAF = runAF >>> first (($ ()) <$>)
The dual is also potentially useful, where you use (flip (<.>)) instead.
I'm not sure if this is useful for Jeremy's goal, but it's an
interesting direction t
Here's a tip: leave off the type signature, and ask ghci what it is.
$ ghci
Prelude> let contain x [] = False ; contain x (y:ys) = if x == y then
True else contain x ys
Prelude> :t contain
contain :: (Eq a) => a -> [a] -> Bool
-- ryan
2008/12/22 Raeck Zhao :
> I am trying to define a containin
I think that there's no solution for your problem as stated, besides
going with something like type-indexed monads, which leads you down
the no-implicit-prelude path.
But to see one obvious reason why this is the case: can you tell me
what the type of "returnAF" is?
Also, one of the monad laws is
You shouldn't need forkOS, but without -threaded (and related RTS
switches to enable multithreading) I think you are sunk. Without
enabling multithreading support, you are saying that your program
(which might use concurrency features of Haskell) will run on a single
OS thread. During a foreign c
The problem is that you are trying to return a mutable array out of an
ST computation. This lets the "mutability" of the computation escape.
That's what the "s" type variable is for; without it, runST is just
unsafePerformIO.
To solve your problem, you need to eliminate any references to the
st
You have a few options.
In Haskell98 (no extensions):
a () = (f,f)
g () = fst (a ())
-- alternatively
g x = fst (a ()) x
Here you make it explicit that "a" and "g" are functions; the
monomorphism restriction is there to stop things that look like values
(and therefore you expect to only get eval
heck == 4
bigEndian = endianCheck == 1
-- ryan
On Thu, Dec 18, 2008 at 4:33 AM, Ryan Ingram wrote:
> I think something like this might work:
>
> Prelude GHC.Exts GHC.Word> let W64# x = 0x10002 in W32# (unsafeCoerce# x)
> 2
>
> You should get 1 for big-endian and 2 for littl
I think something like this might work:
Prelude GHC.Exts GHC.Word> let W64# x = 0x10002 in W32# (unsafeCoerce# x)
2
You should get 1 for big-endian and 2 for little-endian.
(Disclaimer: not particularily well-tested.)
-- ryan
On Thu, Dec 18, 2008 at 3:27 AM, Mauricio wrote:
> Hi,
>
> Is
On Thu, Dec 18, 2008 at 3:01 AM, Robin Green wrote:
> In my opinion, in Haskell, you don't need coroutines because you have
> lazy evaluation.
That's a fair criticism. Lazy evaluation basically gives you a
coroutine embedded in any data structure. But sometimes making
implicit things explicit a
On Thu, Dec 18, 2008 at 2:00 AM, Nicolas Pouillard
wrote:
> I don't see why one would need session types, channels... to express that.
> I maybe need a more complicated coroutines (ruby) example that would require
> using this system.
OK, how would you type these routines in Haskell?
def simple
2008/12/18 Luke Palmer :
> On Thu, Dec 18, 2008 at 1:53 AM, Cetin Sert wrote:
>>
>> Hi,
>>
>> I tested the following, why does the rewrite rules not fire when using
>> tuples also in testRewrite2, testRewriteReverse2?
>
>> testRewrite2 :: a → (Bool,Bool)
>> testRewrite2 x = (pf,pi)
>> where
>>
Andrew was recently asking about co-routines. A couple of years ago,
I was in much the same position as him; although I am pretty sure I
had heard the term before, it seemed like a mysterious idea with no
practical use.
Then I learned Ruby. Ruby makes extensive use of coroutines; it's not
uncomm
It's absolutely possible. However, I think you do need to enumerate
the possible types somehow.
Here's an example that demonstrates the idea:
> {-# LANGUAGE ScopedTypeVariables #-}
> sizedTree :: forall a. Arbitrary a => Int -> Gen (Tree a)
> sizedTree n | n <= 0 = liftM Val arbitrary
> sizedTre
Oops, misread a bit. I thought this was your series of posts, Andrew!
But other than that, my points stand :)
-- ryan
On Wed, Dec 17, 2008 at 12:13 AM, Ryan Ingram wrote:
> In the last "episode" you talk about an entity's update being a function like:
>
>> i
301 - 400 of 721 matches
Mail list logo