On Wed, Aug 31, 2011 at 6:13 AM, Ryan Ingram <[email protected]> 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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe