[Haskell-beginners] Re: data constructors
Sterling Clover
s.clover at gmail.com
Tue Apr 21 22:18:49 EDT 2009
Maybe just bikeshedding here (and on -beginners, no less), but this
seems like a job for Data.Traversable.sequence?
sequence :: Monad m => t (m a) -> m (t a)
Cheers,
S.
On Apr 20, 2009, at 3:00 AM, Heinrich Apfelmus wrote:
>
> Functors sounds good to me.
>
> data Named a = N Name a
> data Timed a = T Time a
>
> instance Functor Named where ...
> instance Functor Timed where ...
>
> convert :: Named [Timed Chord] -> Timed [Named Chord]
>
>
> Bu you can also use plain type synonyms
>
> type Named a = (Name,a)
> type Timed a = (Time,a)
>
> and write your own record selectors by hand
>
> name :: Named a -> Name
> name = fst
>
> time :: Timed a -> Time
> time = fst
>
> value :: (b,a) -> a
> value = snd
>
>
>
> Regards,
> apfelmus
>
> --
> http://apfelmus.nfshost.com
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list