Commit 6cc65fc3 authored by Steffen Michels's avatar Steffen Michels

add gEq,JSON instance for MaybeError

parent 5685b476
Pipeline #14954 passed with stage
in 1 minute and 9 seconds
......@@ -4,6 +4,7 @@ from Data.Functor import class Functor
from Control.Monad import class Monad
from Control.Applicative import class Applicative
from Data.Maybe import :: Maybe
from Data.GenEq import generic gEq
/**
* A type representing something that may have failed.
......@@ -22,6 +23,8 @@ instance Functor (MaybeError a)
instance Applicative (MaybeError a)
instance Monad (MaybeError a)
derive gEq MaybeError
/**
* Return True when the argument is an Ok value and return False otherwise.
*/
......
implementation module Data.Error
import StdMisc
import Data.Functor, Data.Maybe
import Data.Functor, Data.Maybe, Data.GenEq
import Control.Monad
import Control.Applicative
......@@ -19,6 +19,8 @@ instance Monad (MaybeError e) where
bind (Error l) _ = Error l
bind (Ok r) k = k r
derive gEq MaybeError
isOk :: !(MaybeError a b) -> Bool
isOk (Ok _) = True
isOk (Error _) = False
......
definition module Data.Error.GenJSON
from Data.Error import :: MaybeError
from Text.GenJSON import generic JSONEncode, generic JSONDecode, :: JSONNode
from Data.Maybe import :: Maybe
derive JSONEncode MaybeError
derive JSONDecode MaybeError
implementation module Data.Error.GenJSON
import Data.Error, Text.GenJSON
derive JSONEncode MaybeError
derive JSONDecode MaybeError
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment