[<<][haskell][>>][..]
Wed May 30 21:18:57 EDT 2018

Hidden state

Time to revisit:

I want to define composition for stateful computations

Which is an applicative functor, except for the extra state.

Can this be hidden?

Yes is the answer.

And I did this before as  ~/meta/dspm/Sys.hs:

data Sys stx m i o = 
  forall s. (CSSM stx m s i o) => Sys (SSM m s i o)

class CSSM stx m s i o where
  ssmCompile :: SSM m s i o -> stx

So you can make this work as long as you define an interface.  Above,
the interface is "can be compiled to some syntax datatype".  Which is
really the only thing we want to do with "open" code.

It's time to fish out that library, clean it up and put it on github.
I did rewrite that whole thing as an Applicative and Arrow.  Something
like this:

data Sig stx m o = 
  forall s. (CSig stx m s o) => Sig (s, s -> m (s, o))

class CSig stx m s o where
  compileSig :: (i -> CSig stx m s o) -> stx

Where is the last version of that code?

~/git/siso

    Signal.hs               4265 Haskell          ~/git/siso/src/Signal.hs
    RSignal.hs              1778 Haskell          ~/git/siso/src/RSignal.hs

I believe there are issues with the latter one.



[Reply][About]
[<<][haskell][>>][..]