Hi,
I'm extract this fragment of code from my tesis program.
I'm try to reduce more, but i can't.
The concrete question is: What does {_Gc Black Hole} mean?
=======================================================
===== Concrete problem here, implementation later =====
=======================================================
I'm execute mainOk and receive the expected result
Main> mainOk
Dyn Hello World!!
(82 reductions, 196 cells)
I'm execute main and system stop, not reduction executed
(27 reductions in five minutes of wait)
Main> main
{Interrupted!}
(27 reductions, 64 cells)
I'm expected Dyn
class Result r where toString :: r -> String fromString :: String -> r toR :: Result r' => r -> r' fromR :: Result r' => r'-> r
======================================================= ============ Class SubResult ========================== =======================================================
class Result a => SubResult a where toHtml :: a -> Html fromHtml :: Html -> a
======================================================= ========= Html data type ============================== =======================================================
newtype Html = Html String deriving Show
======================================================= ========= Html are Result and SubResult =============== =======================================================
instance Result Html where toString (Html st) = st fromString st = Html ("<" ++ st ++ ">") toR (Html st) = toR st fromR r = toR r
instance SubResult Html where toHtml = id fromHtml = id
======================================================= =========== Dyn data type ============================= =======================================================
data Dyn = forall a . SubResult a => Dyn a
instance Show Dyn where show (Dyn x) = "Dyn " ++ toString x
======================================================= =========== Dyn are Result and SubResult ============== =======================================================
instance Result Dyn where toString (Dyn x) = toString x fromString st = Dyn st fromR = toR toR (Dyn x) = toR x
instance SubResult Dyn where toHtml (Dyn x) = toHtml x fromHtml html = Dyn html
======================================================= ============ String are Result and SubResult ========== =======================================================
instance Result String where toString = id fromString = id fromR = toString toR = fromString
instance SubResult String where toHtml st = fromString st fromHtml html = toString html
======================================================= =============== Rule Class ============================ =======================================================
class (Result r) => Rule e r where apply :: e r -> r -> r rws :: (Result r') => (r -> r') -> e r
======================================================= =============== SubRule Class ========================= =======================================================
class (Rule e r, SubResult r) => SubRule e r where rwsS :: (SubResult r') => (r -> r') -> e r
======================================================= ======== TRule data type ============================== =======================================================
newtype TRule r = TRule (r -> r)
======================================================= ========= TRule are Rule ============================== =======================================================
instance Result a => Rule TRule a where apply (TRule f) r = f r rws f = TRule (\r -> toR (f r))
======================================================= =========TRule are SubRule ============================ =======================================================
instance SubResult a => SubRule TRule a where rwsS f = TRule (\r -> toR $ toHtml (f r))
======================================================= ========== Examples =================================== =======================================================
genRule1 :: Rule e r => e r genRule1 = rws (\r -> toR r ++ "!!")
genRule2 :: SubRule e r => e r genRule2 = rwsS (\r -> toR r ++ "!!")
mainOk:: Dyn mainOk = apply (genRule1::TRule Dyn) (toR "Hello World")
main :: Dyn main = apply (genRule2::TRule Dyn) (toR "Hello World")
======================================================== ===================== The end ========================== ======================================================== Saludos Pablo "Yeti" Cardenal from La Plata, Buenos Aires, Argentina