Skip to content

Generalize HordeAd.External.Adaptor from [a] to Traversable a and also to MonoTraversable #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Mikolaj opened this issue Nov 21, 2022 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Mikolaj
Copy link
Owner

Mikolaj commented Nov 21, 2022

Currently, the Adaptor instance for lists if inefficient and the instance for sized lists ListR is similarly costly, though in a different way, but that doesn't mean we can't generalize from lists to Traversable at least.

The old description below this line is completely outdated.


This would need to be changed a lot, because for definition

instance (AdaptableDomains a, Traversable t)
         => AdaptableDomains (t a) where
  type Scalar (t a) = Scalar a
  toDomains l = unefined  -- use unzip x = (fmap fst x, fmap snd x), etc.
  fromDomains lInit source =
    let f = swap . flip fromDomains
    in swap $ mapAccumL f source lInit

I'm getting errors like

src/HordeAd/External/Adaptor.hs:237:8: error:
    Conflicting family instance declarations:
      Scalar (t a) = Scalar a
        -- Defined at src/HordeAd/External/Adaptor.hs:237:8
      Scalar (a, b, c) = Scalar a
        -- Defined at src/HordeAd/External/Adaptor.hs:271:8
    |
237 |   type Scalar (t a) = Scalar a
    |        ^^^^^^

src/HordeAd/External/Adaptor.hs:245:8: error:
    Conflicting family instance declarations:
      Value (t a) = t (Value a)
        -- Defined at src/HordeAd/External/Adaptor.hs:245:8
      Value (a, b) = (Value a, Value b)
        -- Defined at src/HordeAd/External/Adaptor.hs:312:8
    |
245 |   type Value (t a) = t (Value a)
    |        ^^^^^
@Mikolaj Mikolaj added enhancement New feature or request help wanted Extra attention is needed labels Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant