[Haskell-cafe] I'm trying to design a GUI library -- a design question

Niklas Haas haskell at nand.wakku.to
Mon Mar 3 12:56:55 UTC 2014


	<CAMQQO3mLWxjR_cydOdDZR_i6=Mgi3asTWsNDY8tzQcRc95uYtA at mail.gmail.com>
	<20140302213802.GA17085 at machine>
	<CAMQQO3mRBzzjCCboLPcFKXcQfSuS39BV99zL8+ox=v-Mo+Gdiw at mail.gmail.com>
	<20140303080645.GB2069 at machine> <20140303081048.GC2069 at machine>
	<CAMQQO3kgL+stx9OL0JCn6CmvS4h3Us1-vm9ZDjvMRiuUEQZGGw at mail.gmail.com>
	<CAMQQO3nAZBV5ZDoVuwKWO+aRP94702CjpWG4DZ8x6+LuwPMPPg at mail.gmail.com>
	<20140303101441.GA4636 at machine>

On Mon, 3 Mar 2014 11:14:41 +0100, Daniel Trstenjak <daniel.trstenjak at gmail.com> wrote:
> 
> Hi Ömer,
> 
> I don't think that you need the 'HasWidgets' class, it really doesn't give you a lot.
> Something like a function 'withFocused' would be a lot more useful:
> 
>    withFocused :: (Widget -> Widget) -> State Program ()
> 
> 
> Greetings,
> Daniel
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

This looks like a use case for a lens to me.

> focused :: Lens' Program Widget
> over focused :: (Widget -> Widget) -> Program -> Program

> (focused %=) :: MonadState Program m => (Widget -> Widget) -> m ()
> zoom focused :: (MonadState Widget m, MonadState Program n) => m a -> n a


More information about the Haskell-Cafe mailing list