On Thu, Dec 24, 2009 at 9:36 AM, Roel van Dijk <vandijk.r...@gmail.com> wrote: > On Thu, Dec 24, 2009 at 2:54 PM, Gwern Branwen <gwe...@gmail.com> wrote: >> The idea is that it contains a mapping, String -> (Unicode) Char; it >> is used in Yi for a 'pretty lambdas'-like mode where the text file >> remains unchanged but the visual display in the terminal or whatever >> shows the respective Unicode symbol in place of the long ASCII name. >> This is, I think, similar to the unicode-symbols packages except >> instead of defining the symbols directly, it allows replacement. It is >> a slightly different change of emphasis. >> (Offhand, I wonder whether it would be possible to use TH to generate >> the function aliases directly from Yi.Char.Unicode's mapping? Probably >> not, since you would have to evaluate the Strings/Chars.) > > So what is shared between my packages, Péter's package and > Yi.Char.Unicode is a mapping (Name → Symbol). So ideally you > only want to define in a single place that: > > elem = ∈ > . = ∘ > && = ∧ > etc.. > > Which could then be used in a number of ways: > * Writing actual code: unicode-prelude, base-unicode-symbols > * Different view on existing code: unicodifying Gitit plugin, > emacs-mode fontlock symbols > * Haddock / hscolour? > > But what would be the type of the mapping? A type like > > mapping ∷ String → String > > doesn't seem to bad at a first glance, but how would you generate > the following definitions based on such a mapping: > > (∈) ∷ Eq α ⇒ α → [α] → Bool > (∈) = Data.List.elem > > (∈) ∷ Ord α ⇒ α → Set α → Bool > (∈) = Data.Set.elem > > (∈) ∷ Ord k ⇒ k → Map k α → Bool > (∈) = Data.Map.elem > > each with infix 4 ∈ > > or > > (∘) ∷ (b → c) → (a → b) → (a → c) > (∘) = (Data.Function..) -- correct syntax > > (∘) ∷ Category cat ⇒ cat b c → cat a b → cat a c > (∘) = (Control.Category..) > > each with infixr 9 ∘ > > I agree that a single definition of the mapping is better than a > number of separate ones but I do not yet see a way to encode it > in Haskell. Perhaps we could create a wiki page to document the > definitions and discuss possible new unicode symbols. >
If there are multiple alternatives, then return a list, maybe, of functions? That's the usual approach - 'list of successes' etc. (Unless I'm misunderstanding your point about types.) -- gwern -- Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel