Skip to content

Inconsistent usage/requirement of SListI #175

@phadej

Description

@phadej

For example, zipList_NP requires SListI:

zipWith_NP :: SListI xs => (forall a. f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs

However, compare_NS and compare_SOP, don't require nor provide one:

compare_NS ::
     forall r f g xs .
     r                             -- ^ what to do if first is smaller
  -> (forall x . f x -> g x -> r)  -- ^ what to do if both are equal
  -> r                             -- ^ what to do if first is larger
  -> NS f xs -> NS g xs
  -> r
  
compare_SOP ::
     forall r f g xss .
     r                                      -- ^ what to do if first is smaller
  -> (forall xs . NP f xs -> NP g xs -> r)  -- ^ what to do if both are equal
  -> r                                      -- ^ what to do if first is larger
  -> SOP f xss -> SOP g xss
  -> r
compare_SOP lt eq gt (SOP xs) (SOP ys) =
  compare_NS lt eq gt xs ys

which requires to use ccompare_NS variants with Top: compare_SOP ... (\xs ys -> ... $ zipList_NP xs ys) doesn't work.


I'd prefer a fix where functions which don't require SList (like map_NP and zipWith_NP) won't actually require it (i.e. fix them, not compare_NS). The reasoning being two fold

  • Less "linear sized" data passed around (and constructed)
  • If zipWith_NP is used on something else than a [Type] kind. Maybe it's [[Type]] or [[[Type]]], maybe there's something not in sop-core (e.g. type-level Maybe with its own All-like class). So zipWith_NP cannot be ever general enough, and then it's better to use czipWIth_NP. But zipWith_NP is stilluseful, when you are not threading any constraints. (Except it isn't know, as SListI needs to be threaded, or recovered from argument NP).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions