scala - How to compose prameterized-types in scalaz validation? -


i've got code this:

import scalaz._, scalaz._  case class cat(                       val lang: string,                       val title: string,                       val icon: string,                       val count: int,                       val id: option[long])  case class invaliddataexception[t](                                      msg:string,                                      val value:t,                                      cause:option[throwable] = none )    extends exception ( msg, cause getorelse null )  trait categoryservice {     private type notemptyerrorlist = nonemptylist[invaliddataexception[_]]    private type _validation = validation[notemptyerrorlist,category]     def createcategory(                         lang: string,                         title: string,                         icon: string,                         channels:string,                         channelcount:int = 0)(                         implicit availablelangs: list[string],                         session: sqlsession): _validation = {        val _tlang = lang.trim       val _lang = if( !availablelangs.contains(_tlang) )          invaliddataexception(s"lang invalid: ${lang}", lang).failurenel       else _tlang.successnel        val _ttitle = title.trim       val _title = if( _ttitle.isempty )          invaliddataexception("title can't empty", title ).failurenel       else _ttitle.successnel        val _ticon = icon.trim       val _icon = if( _ticon.isempty )          invaliddataexception("icon empty", icon).failurenel       else _ticon.successnel        val _count = if( channelcount < 0 )          invaliddataexception(s"invalid count channels: ${channelcount}", channelcount).failurenel       else channelcount.successnel        ( _lang |@| _title |@| _icon |@| _count ) { (lang, title, icon, count) =>          cat(lang, title, icon, count, none)       }    }  } 

when try compile code, error:

[error] ~/i/prjs/.../cat.scala:62: type mismatch; [error]  found   : scalaz.validation[scalaz.nonemptylist[invaliddataexception[int]],int] [error]  required: scalaz.validation[scalaz.nonemptylist[invaliddataexception[string]],?] [error]       ( _lang |@| _title |@| _icon |@| _count ) { (lang, title, icon, count) => [error]                                        ^ 

i know can cast type any - mannually :

private type _v[t] = validation[notemptyerrorlist,t] ... val _lang:_v[string] = ... 

but prefer compiler me! there way pass error? why compiler can't cast ?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -