기본적으로 Either와 Maybe 중첩 된 형식의 Functor 인스턴스에 문제가 있습니다.Either와 Maybe로 구성된 Type의 Functor 인스턴스를 만드는 방법
data Tuple a b = Tuple a b
data Primitive = String String | Boolean Boolean | Number Number | Null
data JsonValue = Object (Map String JsonValue) | Array (List JsonValue) | Primitive
type Path = List String
data JsonGraphValue = JsonGraphObject (Map String JsonGraphValue) | Atom JsonValue | Ref Path | Error JsonValue | JsonPrimitive Primitive
newtype JsonGraphRecResult a = JsonGraphRecResult (Either String (Tuple (Maybe a) (List Path)))
instance jsonGraphRecResultFunctor :: Functor JsonGraphRecResult where
map f (JsonGraphRecResult (Right (Tuple (Just value) paths))) = JsonGraphRecResult (Right (Tuple (Just (f value)) paths))
map f value = value
위 코드의 끝에있는 "value"단어를 가리키는 다음 오류가 발생합니다. JsonGraphRecResult 잘 컴파일 다음 ㅋ 유형에서 어떤 다른 이유
Could not match type
a1
with type
b0
while trying to match type JsonGraphRecResult a1
with type JsonGraphRecResult b0
while checking that expression value
has type JsonGraphRecResult b0
in value declaration jsonGraphRecResultFunctor
where b0 is a rigid type variable
a1 is a rigid type variable
그것은 내게 분명하지 않다 :
newtype Blah a = Blah (Maybe a)
instance blahFunctor :: Functor Blah where
map f (Blah (Just x)) = Blah (Just (f x))
map f value = value
다음 gist 위해 "PureScript 시도"온라인 REPL에 직접 붙여 넣을 수 있습니다 오류를 복제합니다.