Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:55:03+00:00 2026-06-10T11:55:03+00:00

I have code like: type StringValidation[+A] = Validation[String, A] type WriterValidation[A] = WriterT[StringValidation, String,

  • 0

I have code like:

type StringValidation[+A] = Validation[String, A]
type WriterValidation[A] = WriterT[StringValidation, String, A]
type Result[A] = WriterValidation[A]

private def someResult: Result[Int]
def implementTrait: Result[Any] = someResult    // type mismatch

it gives type mismatch, found Result[Int], required Result[Any], but if I change it to:

type WriterValidation[+A] = WriterT[StringValidation, String, A]

it gives “covariant type A occurs in invariant position in WriterT…”

it occurs to me that the operation should be Okay in concept, Validation can be covariance, why WriterT could not (or is not) decared WriterT[F[_], W, +A] (or even with +W)?

I’m using scalaz7 snapshot, but I see that the declaration of WriterT in 6.0.4 is the same.


Solved.
it turns out that I used the wrong version, what I used was "org.scalaz" %% "scalaz-core" % "7.0-SNAPSHOT", once I switched to "org.scalaz" % "scalaz-core_2.9.2" % "7.0.0-M2" it’s ok

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:55:05+00:00Added an answer on June 10, 2026 at 11:55 am

    Not sure about your situation, but scalaz-seven tree (and also the M2 release) has covariant type args.

        sealed trait WriterT[F[+_], +W, +A] { ...
    

    Also the following works:

        scala> type SV[+A] = Validation[String, A]
    defined type alias SV
    
    scala> type WV[+A] = WriterT[SV, String, A]
    defined type alias WV
    
    scala> type Result[+A] = WV[A]
    defined type alias Result
    
    scala> def someResult: Result[Int] = ???
    someResult: Result[Int]
    
    scala> def implementTrait: Result[Any] = someResult
    implementTrait: Result[Any]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) {
I have code like this: type TMyDictionary = TDictionary<int, int>; var myDict: TMyDictionary; k,
I have code like this: Type typPrecise = MostPrecise(typeof(int), typeof(double));//Evaluates to double var varGeneric
I have code like this: class MapIndex { private: typedef std::map<std::string, MapIndex*> Container; Container
I have a code like this public static Type ToType(XmlSerializableType xmlSerializableType) { string func
So when I have code like: shared_ptr<Foo> bar (my_normal_operator<Foo>(mumble)); Even though the type Foo
I have seen code like this (actually seeing another person type it up): catch
I have code that I want to look like this: List<Type> Os; ... foreach
I have a UserControl, in the Resources section I have code like <Style TargetType={x:Type
i have code like this: <script type=text/javascript> var _gaq = _gaq || []; _gaq.push(['_setAccount',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.