require "rubygems"
require "bud"
class TcSortPro
include Bud
state do
interface input, :dump, [:payload]
interface output, :pickup, [:ident] => [:payload]
end
bloom do
pickup <= dump.sort.each_with_index.map {|a, i| [i, a]}
end
end
TcSortPro.new.run_bg
The problem appears to be that map2pro in rewrite.rb changes the map call into a pro call. map2pro claims that to "Look for top-level map on a base-table on rhs, and rewrite to pro", but clearly it bites off more than it can chew here.
Two fixes come to mind:
Make map2pro more conservative, by actually checking that the map is being applied to a Bud collection
Monkeypatch Enumerable::Enumerator to define pro as an alias for map
Implementing #1 might be hard without ruling-out some cases where the rewrite can be done safely (e.g., rewrite applied to an expression that returns a BudCollection).
I think this should be legal Bloom code:
However, it fails:
The problem appears to be that
map2pro
in rewrite.rb changes themap
call into apro
call.map2pro
claims that to "Look for top-level map on a base-table on rhs, and rewrite to pro", but clearly it bites off more than it can chew here.Two fixes come to mind:
map2pro
more conservative, by actually checking that themap
is being applied to a Bud collectionpro
as an alias formap
Implementing #1 might be hard without ruling-out some cases where the rewrite can be done safely (e.g., rewrite applied to an expression that returns a BudCollection).