Haskell w/ delimited continuations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Haskell w/ delimited continuations

Taral
My understanding of these things is limited, but what would stop me,
theoretically speaking, of making a version of ghc with these
primitives added:

type Prompt r

reset :: (Prompt r -> r) -> r
shift :: Prompt r -> ((a -> _) -> r) -> a

(Where _ is either r or forall b. b)

--
Taral <[hidden email]>
"Please let me know if there's any further trouble I can give you."
    -- Unknown
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell w/ delimited continuations

Ryan Ingram
You might want to take a look at
http://www.haskell.org/pipermail/haskell/2007-December/020034.html

which shows an implementation of delimited continuations in Haskell98
and possibly gets rid of any requirement of implementing primitives.

  -- ryan

On 2/22/08, Taral <[hidden email]> wrote:

> My understanding of these things is limited, but what would stop me,
> theoretically speaking, of making a version of ghc with these
> primitives added:
>
> type Prompt r
>
> reset :: (Prompt r -> r) -> r
> shift :: Prompt r -> ((a -> _) -> r) -> a
>
> (Where _ is either r or forall b. b)
>
> --
> Taral <[hidden email]>
> "Please let me know if there's any further trouble I can give you."
>    -- Unknown
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell w/ delimited continuations

Don Stewart-2
See also,

    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CC-delcont

"An implementation of multi-prompt delimited continuations based on the
paper, A Monadic Framework for Delimited Continuations, by R. Kent
Dybvig, Simon Peyton Jones and Amr Sabry"

    reset :: MonadDelimitedCont p s m => (p a -> m a) -> m a
    shift :: MonadDelimitedCont p s m => p b -> ((m a -> m b) -> m b) -> m a

ryani.spam:

> You might want to take a look at
> http://www.haskell.org/pipermail/haskell/2007-December/020034.html
>
> which shows an implementation of delimited continuations in Haskell98
> and possibly gets rid of any requirement of implementing primitives.
>
>   -- ryan
>
> On 2/22/08, Taral <[hidden email]> wrote:
> > My understanding of these things is limited, but what would stop me,
> > theoretically speaking, of making a version of ghc with these
> > primitives added:
> >
> > type Prompt r
> >
> > reset :: (Prompt r -> r) -> r
> > shift :: Prompt r -> ((a -> _) -> r) -> a
> >
> > (Where _ is either r or forall b. b)
> >
> > --
> > Taral <[hidden email]>
> > "Please let me know if there's any further trouble I can give you."
> >    -- Unknown
> > _______________________________________________
> > Haskell-Cafe mailing list
> > [hidden email]
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell w/ delimited continuations

Taral
In reply to this post by Taral
On 2/22/08, Taral <[hidden email]> wrote:
>  reset :: (Prompt r -> r) -> r
>  shift :: Prompt r -> ((a -> _) -> r) -> a

The point of the question is about shift/reset with *these types*. I
know there are implementations with other types.

--
Taral <[hidden email]>
"Please let me know if there's any further trouble I can give you."
    -- Unknown
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: Haskell w/ delimited continuations

Derek Elkins
On Fri, 2008-02-22 at 14:27 -0800, Taral wrote:
> On 2/22/08, Taral <[hidden email]> wrote:
> >  reset :: (Prompt r -> r) -> r
> >  shift :: Prompt r -> ((a -> _) -> r) -> a
>
> The point of the question is about shift/reset with *these types*. I
> know there are implementations with other types.


Nothing but sanity is stopping you.  If you make a new language, you can
do whatever you like.  However, with shift and reset you can represent
any effect, so you would utterly lose purity.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: Haskell w/ delimited continuations

Taral
On 2/22/08, Derek Elkins <[hidden email]> wrote:
> Nothing but sanity is stopping you.  If you make a new language, you can
>  do whatever you like.  However, with shift and reset you can represent
>  any effect, so you would utterly lose purity.

Can you give an example of an impure function created using these primitives?

--
Taral <[hidden email]>
"Please let me know if there's any further trouble I can give you."
    -- Unknown
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: Haskell w/ delimited continuations

Derek Elkins
On Fri, 2008-02-22 at 15:13 -0800, Taral wrote:
> On 2/22/08, Derek Elkins <[hidden email]> wrote:
> > Nothing but sanity is stopping you.  If you make a new language, you can
> >  do whatever you like.  However, with shift and reset you can represent
> >  any effect, so you would utterly lose purity.
>
> Can you give an example of an impure function created using these primitives?

shift and reset

but see these slides
http://cs.ioc.ee/mpc-amast06/msfp/filinski-slides.pdf
and/or one or both of
http://citeseer.ist.psu.edu/filinski94representing.html
http://citeseer.ist.psu.edu/filinski99representing.html

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: Haskell w/ delimited continuations

Taral
On 2/22/08, Derek Elkins <[hidden email]> wrote:
> shift and reset

I was under the impression that reset was a pure function. What side
effects does it have?

--
Taral <[hidden email]>
"Please let me know if there's any further trouble I can give you."
    -- Unknown
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: Haskell w/ delimited continuations

Derek Elkins
On Fri, 2008-02-22 at 19:04 -0800, Taral wrote:
> On 2/22/08, Derek Elkins <[hidden email]> wrote:
> > shift and reset
>
> I was under the impression that reset was a pure function. What side
> effects does it have?

It depends on how you define "pure function".  It's not particularly
relevant and I mostly included it as I consider them a pair.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell w/ delimited continuations

Taral
In reply to this post by Taral
On 2/22/08, Taral <[hidden email]> wrote:
>  shift :: Prompt r -> ((a -> _) -> r) -> a
>
>  (Where _ is either r or forall b. b)

It occurs to me that _ has to be r, otherwise the subcontinuation can escape.

--
Taral <[hidden email]>
"Please let me know if there's any further trouble I can give you."
    -- Unknown
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe