packages feed

retrie-2.0.0: tests/inputs/Parens.test

# Copyright (c) 2025 Andrew Farmer
# Copyright (c) 2020-2024 Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
-u Parens.foo 
-u Parens.bar 
-u Parens.quux 
-u Parens.blarg
-u Parens.shl1
-u Parens.neg
-u Parens.two
-u Parens.mkR
--adhoc "forall a. a . id = a"
--type-forward Parens.Fn
--type-forward Parens.MaybeInt
===
 {-# LANGUAGE OverloadedRecordDot #-}
 module Parens where
 
 import Data.Bits
 
 foo :: Int
 foo = 3 + 4
 
 bar :: Int
-bar = 5 `quot` foo
+bar = 5 `quot` (3 + 4)
 
 baz :: Int
-baz = quux bar
+baz = foo * bar
 
 baz2 :: Int
-baz2 = foo `quot` bar
+baz2 = (3 + 4) `quot` (5 `quot` foo)
 
 quux :: Int -> Int
-quux x = foo * x
+quux x = (3 + 4) * x
 
 splat :: Int
-splat = undefined foo
+splat = undefined (3 + 4)
 
 blarg :: Int -> Int
 blarg =
   case 54 of
     0 -> pred
     _ -> succ
 
 blerg :: Int
-blerg = blarg 42
+blerg = (case 54 of
+    0 -> pred
+    _ -> succ) 42
 
 jank :: IO (Int -> Int)
-jank = return blarg
+jank = return (case 54 of
+    0 -> pred
+    _ -> succ)
 
 jenk :: IO Int
-jenk = return $ blarg 42
+jenk = return $ (case 54 of
+    0 -> pred
+    _ -> succ) 42
 
 shl1 :: Int -> Int
 shl1 n = n `shiftL` 1
 
 shl2 :: Int -> Int
-shl2 = (`shiftL` 2) . id
+shl2 = (`shiftL` 2)
 
 shl3 :: Int -> Int
-shl3 n = shl1 n `shiftL` 2
+shl3 n = n `shiftL` 1 `shiftL` 2
 
 shl4 :: Int -> Int
-shl4 n = n `shiftL` shl1 2
+shl4 n = n `shiftL` (2 `shiftL` 1)
 
 mixedDirs :: Int
-mixedDirs = shl1 3 ^ shl1 4
+mixedDirs = (3 `shiftL` 1) ^ (4 `shiftL` 1)
 
 sectL :: Int -> Int
-sectL = (foo +)
+sectL = (3 + 4 +)
 
 sectR :: Int -> Int
-sectR = (+ foo)
+sectR = (+ (3 + 4))
 
 neg :: Int
 neg = negate $ 1
 
 sectLower :: [Int] -> [Int]
-sectLower = (neg :)
+sectLower = ((negate $ 1) :)
 
 two :: [Int]
 two = [1] ++ [2]
 
 sectAssoc :: [Int] -> [Int]
-sectAssoc = (two ++)
+sectAssoc = (([1] ++ [2]) ++)
 
 -- a record update's head must be atomic
 data R = R { r1 :: Int, r2 :: Int }
 
 mkR :: R
 mkR = let x = 1 in R x 2
 
 updR :: R
-updR = mkR { r2 = 3 }
+updR = (let x = 1 in R x 2) { r2 = 3 }

 -- a projection's head must be atomic
 proj :: Int
-proj = mkR.r1
+proj = (let x = 1 in R x 2).r1

 -- prefix minus binds like an infix-6 operator
 negFoo :: Int
-negFoo = - foo
+negFoo = - (3 + 4)

 negBar :: Int
-negBar = - bar
+negBar = - 5 `quot` foo

 type Fn a b = a -> b
 type MaybeInt = Maybe Int
 
-($!) :: Fn (a -> b) (a -> b)
+($!) :: (a -> b) -> a -> b
 f $! x = f (x)
 
-(&!) :: a -> Fn (a -> b) b
+(&!) :: a -> (a -> b) -> b
 (&!) x f = (f) x
 
-konst :: b -> Fn a b
+konst :: b -> a -> b
 konst x _ = x
 
-noop :: Fn a a
+noop :: a -> a
 noop x = x
 
-idMaybeInt :: MaybeInt -> MaybeInt
+idMaybeInt :: Maybe Int -> Maybe Int
 idMaybeInt x = x
 
-swapEither :: (Either MaybeInt Int) -> Either Int MaybeInt
+swapEither :: (Either (Maybe Int) Int) -> Either Int (Maybe Int)
 swapEither (Left x) = Right x
 swapEither (Right x) = Left x