[Haskell-cafe] Pointed, but not Applicative
Sebastian Fischer
fischer at nii.ac.jp
Wed Aug 31 01:53:51 CEST 2011
On Wed, Aug 31, 2011 at 6:13 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> technically it violates 'fmap id' == 'id' [...]
>
> If you add this FList law, though, you're OK:
>
> runFList fl as = runFList fl [] ++ as
I think the idea of functional lists is that the monoids of 'lists'
and 'functions on lists' are isomorphic with isomorphisms toFList and
toList:
toFList [] = id
toFList (xs++ys) = toFList xs . toFList ys
toList id = []
toList (f . g) = toList f ++ toList g
These can be defined as:
toFList = (++)
toList = ($[])
Eliding newtypes, runFList is just the identity function so we need to check
f l = toList f ++ l
to verify your law. This is the same as
f = toFList (toList f)
which (once we know that toList and toFList are isomorphisms) does
indeed hold because:
toFList . toList = id
toList . toFList = id
Sebastian
More information about the Haskell-Cafe
mailing list