Open AndrasKovacs opened 3 years ago
Related: For certain cases, where you want to parse some data and consume it inside the parser (eventually returning some lifted value), withX# :: (X# -> Parser e a) -> Parser e a
is useful and I think (?) efficient. You still can't return unboxed types, but it can result in fewer allocations (I think). See example usage in an file table format (reading data at offsets) here.
Currently we can only return
LiftedRep
types from parsers. Sometimes this performs poorly, when we want to parseInt
,Double
, or other directly unboxable types. While sometimes it's possible to avoid boxing by using tail-recursive functions with unboxed accumulators, it's generally more convenient (and possibly more efficient) if we can use non-tail recursion and basic combinators with unboxed return values.Unfortunately the ergonomics of levity polymorphism is awful. Example: https://hackage.haskell.org/package/bytesmith-0.3.7.0/docs/Data-Bytes-Parser-Rebindable.html I think something like this would be acceptable, but for the sake of usability more functions should be included in levity-polymorphic classes. This would require boilerplate (or code generation) on the implementation side, but would be hopefully more convenient on user's side.