[Haskell-cafe] Identity of indiscernibles
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Aug 8 18:48:00 CEST 2013
On Thu, Aug 08, 2013 at 05:44:11PM +0100, Tom Ellis wrote:
> On Thu, Aug 08, 2013 at 06:25:12PM +0200, Daniel Trstenjak wrote:
> > > See [1] for an explanation of free monads in general. For IO in particular,
> > > define a functor
> > >
> > > data IOF a = GetChar (Char -> a) | PutChar Char a | ...
> > >
> > > with constructors for all elementary IO operations.
> >
> > But how should this work if the user adds an IO operation, e.g by wrapping a C function?
>
> Wrapping a C function could perhaps be provided by something like
>
> data IOF a = ... | forall i o. Foreign String i (o -> a) | ...
>
> csin :: Double -> IO Double
> csin x = liftF (Foreign "math.h sin" x id)
I suppose that should actually be 'csin :: CDouble -> IO CDouble', but
hopefully the general method is clear.
Tom
More information about the Haskell-Cafe
mailing list