
In the true spirit of wikiwiki comes PreludeExts, all the tiny useful bits of code you think should be in the Prelude, but aren't. http://www.haskell.org/hawiki/PreludeExts Anyway, this started when someone on #haskell wanted a permutations function for the Nth time. I read Koen's "this should be in the Prelude" comment for the Nth time, and PreludeExts was born. If you have small (or not so small) generally useful bits of code, you are invited to put them onto the PreludeExts page. -- Shae Matijs Erisson - 2 days older than RFC0226 #haskell on irc.freenode.net - We Put the Funk in Funktion 10 PRINT "HELLO" 20 GOTO 10 ; putStr $ fix ("HELLO\n"++)

hi, just out of curiosity, have you found any uses for the adjunction class? i spent quite a bit of time playing with adjunctions and they are very useful, but i haven't been able to find particulalry appealing programming examples. this is how i formulated them in haskell: class Functor u => Adjunction f u | f -> u, u -> f where ret :: a -> u (f a) bind :: f a -> (a -> u b) -> b run :: Adjunction f u => f (u a) -> a run m = m `bind` id liftF :: Adjunction f u => (a -> b) -> f a -> f b liftF f m = m `bind` \a -> ret (f a) cobind :: Adjunction f u => a -> (f a -> b) -> u b a `cobind` f = fmap f (ret a) -iavor Shae Matijs Erisson wrote:
In the true spirit of wikiwiki comes PreludeExts, all the tiny useful bits of code you think should be in the Prelude, but aren't.
http://www.haskell.org/hawiki/PreludeExts
Anyway, this started when someone on #haskell wanted a permutations function for the Nth time. I read Koen's "this should be in the Prelude" comment for the Nth time, and PreludeExts was born.
If you have small (or not so small) generally useful bits of code, you are invited to put them onto the PreludeExts page.
-- ================================================== | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | ==================================================

In message <400826CC.6050700@cse.ogi.edu>, "Iavor S. Diatchki" writes:
just out of curiosity, have you found any uses for the adjunction class? i spent quite a bit of time playing with adjunctions and they are very useful, but i haven't been able to find particulalry appealing programming examples.
What I've used Adjunctions for is to represent the relationship between coalgebraic data types (such as streams) and 'paths' in the data structure (for streams, a natural number together with an abstract element representing 'end-of-path' would be such path). The adjunction type class, when interpreted like this, enforces the constraint that every path leads to exactly one element of the data structure [due to the type of the counit]. So to me it would seem that the Adjunction type class is useful at least when the right adjoint is the functor of a coalgebra and the left adjoint is a functor of an algebra that exactly matches the structure of the coalgebra. I've put an example to http://haskell.org/hawiki/PreludeExtsUseExamples. -- Esa Pulkkinen

Shae Matijs Erisson writes: | In the true spirit of wikiwiki comes PreludeExts, all the tiny | useful bits of code you think should be in the Prelude, but aren't. | | http://www.haskell.org/hawiki/PreludeExts The very first function in there box x = [x] reminds me of a style issue which doesn't get much attention. The issue is vocabulary. If I'm reading someone else's code (or my own old code), this map box xs may well sidetrack me onto finding the definition of box, whereas this map (\x -> [x]) xs is more self contained, and not much longer. (I don't mean any offence to the author and users of 'box'; it's a matter of personal preference, how big a function neds to be before it deserves a name.) Regards, Tom

In local.libraries, you wrote:
box x = [x] map box xs map (\x -> [x]) xs
is more self contained, and not much longer. (I don't mean any offence to the author and users of 'box'; it's a matter of personal preference, how big a function neds to be before it deserves a name.)
I always thought it was natural to use map return xs (obviously with the right context for "return"). It's a pity that 'singleton' went away (or did it never exist in the Prelude at all?). Volker -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME rage against the finite state machine

Am Sonntag, 18. Januar 2004 22:26 schrieb Tom Pledger:
[...]
The very first function in there
box x = [x]
reminds me of a style issue which doesn't get much attention. The issue is vocabulary. If I'm reading someone else's code (or my own old code), this
map box xs
may well sidetrack me onto finding the definition of box, whereas this
map (\x -> [x]) xs
is more self contained, and not much longer. (I don't mean any offence to the author and users of 'box'; it's a matter of personal preference, how big a function neds to be before it deserves a name.)
Since you can use return instead of box, defining box doesn't make much sense to me. When I created a list module with types for non-empty and infinite lists, I asked myself the question if adding a box-like function for non-empty lists would make sense. I dropped this idea since return does the work and having too many functions makes a library's interface unnecessarily complex.
Regards, Tom
Wolfgang
participants (6)
-
Esa Pulkkinen
-
Iavor S. Diatchki
-
Shae Matijs Erisson
-
Tom Pledger
-
Volker Stolz
-
Wolfgang Jeltsch