Reputation: 893
In the purescript-free
package, there is a code example defining this interpreter:
teletypeN :: forall eff. NaturalTransformation TeletypeF (Eff (console :: CONSOLE | eff))
teletypeN (PutStrLn s a) = const a <$> log s
teletypeN (GetLine k) = pure (k "fake input")
How can I define and run another interpreter where the return type is Array Int
or State String Int
?
Upvotes: 1
Views: 162
Reputation: 4649
You can't interpret to a specific value, as interpreters are provided as natural transformations - forall a. f a -> g a
. The a
here can't be "touched" by the function that is doing the interpretation.
You could interpret to Array
or State String
, but the a
will always be determined by the structure you're interpreting. If you know that you only want to interpret Free MyAlgebra Int -> Array Int
then this will all work out anyway.
Upvotes: 4