#5744: List layouts
---------------------------------+------------------------------------------
    Reporter:  nsch              |       Owner:  nsch            
        Type:  feature request   |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.2.1           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by NeilMitchell):

 * cc: ndmitchell@… (added)


Comment:

 Note that you can already use {{{do}}} to define a {{{Monoid}}}:

 {{{
 data Wrap m a = Wrap m a

 unwrap :: Wrap m a -> m
 unwrap (Wrap m a) = m

 wrap :: m -> Wrap m ()
 wrap m = Wrap m ()

 instance Monoid m => Monad (Wrap m) where
     return = Wrap mempty
     Wrap m1 a1 >>= f = Wrap (m1 `mappend` m2) a2
        where Wrap m2 a2 = f a1

 foo :: [Int]
 foo = unwrap $ do
     wrap [1,2,3]
     wrap [4,5]
     wrap [6]
 }}}

 If you sugar up a particular monad and add some nicer types and helper
 functions, it can end up looking quite pleasant. I use this trick in the
 Shake library, so rules can be specified using either do notation or as a
 monoid, even though they are really a monoid.

 (Personally, I agree with Simon Marlow, that it's probably not a problem
 that needs solving - but hopefully the above insight might solve some of
 the issues)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5744#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to