f# - How practical is it to embed the core of a language with an effectful function space (like ML) into Haskell? -
20 years ago, the effective function of languages like MAL as the proposed mogi was in space
- & gt;
Standard total function space = & gt;
Plus can be decomposed into capturing a strong mound T
effect.
A -> B
to a => (TB)
Now, Haskell supports MONADs, including an Io Monad, which is visible enough for the effects in MOL, and has a function space in which => (but partial functions in it also includes) . Therefore, we should be able to translate MAL fragments into Haskell through this decomposition. In theory I think that it works.
My question is whether an embedding can be practical in this way: Is it possible to design the Haskell library, which allows programming in Haskell too far away from HSKL? And if so, what would be the performance?
My criteria for "practical" is that with the widespread use of the effect, existing ML codes can be easily embedded in Haskell, in which the high-order function.
To make this concrete, my own effort on embedding such a transcription below is the main function is the transcription of some simple ML code which essentially generates 5 different variable names Does. Rather than using direct decomposition, my version lifts the functions so that they can evaluate their arguments - there are a mini library with priorities raised in the definitions before the main
. This work is fine, but some aspects are not completely satisfactory.
- Through the
val
there is too much syntax noise for injection of values in computations. With the help of the unwritten versions of the functions of rdV
, it will help in the cost of the need to be defined. - In non-value definitions like
varNum
in & lt; - Monadike binding is required through -
. It compels all the definitions that rely on them, they are in the same code do
. - It seems that the entire program is often considered a huge
expression ML programs, but it is not very well supported in Haskell - for example, you can use equations Are forced to use the case
instead. - I feel somewhat lazy despite the completion of Io Monde. Given that the ML program will be prepared for strict evaluation, laziness should probably be removed. I am uncertain what is the best way to do this. Therefore, to improve it, or on better methods of using similar decomposition, there are quite a different ways to achieve or achieve a uniform broad target of programming in HSKL which mirrors the ML. ? (It's not that I dislike the style of Haskell, it's just that I want to be able to map current ML codes easily.)
Import import data. Import import control Monad Val :: Monad M => A - & gt; I have a val = return ref = join liftm niorf rdV = watchboard - uplift, so a value (! =) R x = do {rr & lt; - R; Xx & lt; - x; WriteIORef rr xx} (. +), (.-) :: IO Int - & gt; IO Int - & gt; IO Int ((. +), (.-)) = (lift M2 (+), lift M2 (-)) (. :) :: IO a - & gt; Io [A] - & gt; Io [A] (. :) = Lift M2 (:) ShowO :: Show A => IOA - & gt; Io String Show IO = LiftM Show Main = Do varNum & lt; - Ref (Val 0) New Weir = (= <<-) <\) - $> (& lt;) Val varNum! = (RdV varNum. + Val 1) & gt; & Gt; Val 'v': (Shōio (RDV varNum) GL = (= & lt; & lt;) $ \ n - & gt; Case of 0 - n - & gt; Return [] NN - & gt; (NewWare $ vel ()): (Jean (Val N. - Val 1)) General (Val 5) 'A possible way, it does not include Lambodas by Sigf, but it seems that they can be extended to them.
Comments
Post a Comment