b981245c   
   From: bloodymir.crap@gmx.net   
      
   Hi!   
      
   Am 15.11.12 02:01, schrieb Mathias Gaunard:   
   > Then why are you using template template parameters? It seems like   
   > it would be simpler to do Haskell-style programming using   
   > meta-functions of even better, meta-function classes.   
      
   Hmm, it seems natural to model type constructors in Haskell as type   
   constructors in C++ as well. A type constructor is an entity that makes   
   a type from another, just like template classes: consider   
   boost::optional as a unary type constructor that matches a   
   template class M argument of some template:   
      
   Haskell: Maybe Int   
   C++: optional   
      
   Haskell: class Monad m where ...   
   C++: template class M> struct Monad;   
      
   Haskell: instance Monad Maybe where ...   
   C++: template<> struct Monad {...};   
      
   Seems natural to me. So, that was my first approach.   
      
   >> There seems to be no way to make the syntax "Kleisli" produce   
   >> a template template class argument for Arrow. Any ideas?   
   >   
   > Kleisli takes 3 parameters. I don't see why you'd think it would   
   > work with just one, nor what it has to do with specialization.   
      
   Like Scott says it in the other post: "I have been pondering   
   whether or not one can partially apply type-arguments, too, like how a   
   function can be partially applied arguments with std::bind."   
      
   > You could change Kleisli to be something of the kind   
   >   
   > template struct Kleisli { template   
   > struct apply { typedef whatever with M, B and C type; }; };   
      
   Yeah, that would be the workaround. It produces more boilerplate code.   
   And using these, I cannot have a specialization of Arrow<> (I want a   
   single generic implementation of Arrow> no matter which M   
   is used):   
      
   //error for this using your proposal from above:   
   template class M>   
   struct Arrow::apply> //error here   
   { /*...*/ };   
      
   Making the Arrow template accept a regular typename will resolve the   
   issue at the expense of more template hackery (traits class). I thought   
   the whole thing would be easier.   
      
   Frank   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|