[nem-bug] [Nemerle 0000539]: Failed CheckSTV with monad code
feedback at nemerle.org
feedback at nemerle.org
Sun Nov 6 17:43:48 CET 2005
The following issue has been CLOSED
======================================================================
<http://nemerle.org/bugs/view.php?id=539>
======================================================================
Reported By: nazgul
Assigned To: malekith
======================================================================
Project: Nemerle
Issue ID: 539
Category: Compiler
Reproducibility: always
Severity: minor
Priority: high
Status: closed
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 09-28-2005 18:40 CEST
Last Modified: 11-06-2005 17:43 CET
======================================================================
Summary: Failed CheckSTV with monad code
Description:
public interface IMonad[A]
{
/*
* a static unit (return in haskell) method should be part of the
interface
* unit(o:object):Monad --could just be the ctor
*/
bind[B](f : (A -> IMonad[B])) : IMonad[B];
}
public class Continuation[R,A]:IMonad[A]
{
private value : (A -> R) -> R;
public static return (a : A): Continuation[R,A]{
Continuation(fun(k : A -> R){k(a)})
}
public static CallCC[B](f : (A -> Continuation[R,B]) ->
Continuation[R,A]) : Continuation[R,A]{
Continuation(fun(k : A -> R)
{
def g(a : A)
{
Continuation(fun(_: B -> R){k(a)})
};
(f(g)).value(k)
})
}
public this(f : (A -> R) -> R ){
value = f;
}
public bind[B](f : (A -> IMonad[B])) : IMonad[B]{
Continuation(fun(k : B -> R)
{
value(fun (a : A)
{
def g = f(a) :> Continuation[R,B];
g.value(k)
})
})
}
public run(f : A -> R):R
{
value(f)
}
}
public class Driver{
public static Main():void{
def myTry[A,B] (f : ((A -> Continuation[B,A]) * A) ->
Continuation[B,A], x : A){
null : Continuation [int, int]
/*
Continuation.CallCC(fun(e)
{
f(e,x)
})
*/
};
def simpleTryEntry(_ : int -> Continuation[int,int], _ : int){
null
}
//System.Console.WriteLine(myTry(tryEntry,
7).run(fun(a){a}).ToString())
System.Console.WriteLine(myTry(simpleTryEntry,
7).run(fun(a){a}).ToString())
}
}
======================================================================
----------------------------------------------------------------------
malekith - 10-05-05 16:20
----------------------------------------------------------------------
The problem is that a polymorphic functions is used just once, and hence
inlined. As this is not very common situation, I guess I will just prevent
inlining in this case.
----------------------------------------------------------------------
malekith - 10-05-05 19:47
----------------------------------------------------------------------
Resolved on trunk, r5802.
Issue History
Date Modified Username Field Change
======================================================================
09-28-05 18:40 nazgul New Issue
10-03-05 19:34 nazgul Status new => confirmed
10-04-05 21:01 nazgul Priority normal => high
10-05-05 16:20 malekith Note Added: 0000989
10-05-05 19:47 malekith Status confirmed => resolved
10-05-05 19:47 malekith Resolution open => fixed
10-05-05 19:47 malekith Assigned To => malekith
10-05-05 19:47 malekith Note Added: 0000990
10-05-05 19:47 malekith Description Updated
11-06-05 17:43 nazgul Status resolved => closed
======================================================================
More information about the bugs
mailing list