Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- infixl 4 ==., <., <=., >., >=., /=.
- infixl 4 .==., .<., .<=., .>., .>=., ./=.
- infixl 4 .==, .<, .<=, .>, .>=, ./=
- data ACompResult a = TrueCond a | FalseCond
- (==.) :: Eq a => a -> a -> ACompResult a
- (<.) :: Ord a => a -> a -> ACompResult a
- (<=.) :: Ord a => a -> a -> ACompResult a
- (>.) :: Ord a => a -> a -> ACompResult a
- (>=.) :: Ord a => a -> a -> ACompResult a
- (/=.) :: Eq a => a -> a -> ACompResult a
- makeFirstComparison :: (a -> a -> Bool) -> a -> a -> ACompResult a
- makeFirstComparison f x y =
- if f x y
- then TrueCond y -- Comparison successful, carry the right argument on
- else FalseCond -- Comparison failed
- (==.) = makeFirstComparison (==)
- (<.) = makeFirstComparison (<)
- (<=.) = makeFirstComparison (<=)
- (>.) = makeFirstComparison (>)
- (>=.) = makeFirstComparison (>=)
- (/=.) = makeFirstComparison (/=)
- (.==.) :: Eq a => ACompResult a -> a -> ACompResult a
- (.<.) :: Ord a => ACompResult a -> a -> ACompResult a
- (.<=.) :: Ord a => ACompResult a -> a -> ACompResult a
- (.>.) :: Ord a => ACompResult a -> a -> ACompResult a
- (.>=.) :: Ord a => ACompResult a -> a -> ACompResult a
- (./=.) :: Eq a => ACompResult a -> a -> ACompResult a
- makeMiddleComparison :: (a -> a -> Bool) -> ACompResult a -> a -> ACompResult a
- makeMiddleComparison _ FalseCond _ = FalseCond -- Previous failure
- makeMiddleComparison f (TrueCond x) y =
- if f x y
- then TrueCond y -- Comparison successful, carry the right argument on
- else FalseCond -- Comparison failed
- (.==.) = makeMiddleComparison (==)
- (.<.) = makeMiddleComparison (<)
- (.<=.) = makeMiddleComparison (<=)
- (.>.) = makeMiddleComparison (>)
- (.>=.) = makeMiddleComparison (>=)
- (./=.) = makeMiddleComparison (/=)
- (.==) :: Eq a => ACompResult a -> a -> Bool
- (.<) :: Ord a => ACompResult a -> a -> Bool
- (.<=) :: Ord a => ACompResult a -> a -> Bool
- (.>) :: Ord a => ACompResult a -> a -> Bool
- (.>=) :: Ord a => ACompResult a -> a -> Bool
- (./=) :: Eq a => ACompResult a -> a -> Bool
- makeLastComparison :: (a -> a -> Bool) -> ACompResult a -> a -> Bool
- makeLastComparison _ FalseCond _ = False -- Previous failure
- makeLastComparison f (TrueCond x) y = f x y
- (.==) = makeLastComparison (==)
- (.<) = makeLastComparison (<)
- (.<=) = makeLastComparison (<=)
- (.>) = makeLastComparison (>)
- (.>=) = makeLastComparison (>=)
- (./=) = makeLastComparison (/=)
- -- Example:
- -- Haskell> 1 <. 3 .==. 3 .< 6
- -- True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement