module Stg.Prelude.Tuple (
fst,
snd,
curry,
uncurry,
swap,
equals_Pair_Int,
) where
import Prelude ()
import Data.Monoid
import Stg.Language
import Stg.Parser.QuasiQuoter
import Stg.Prelude.Number
fst, snd, curry, uncurry, swap :: Program
equals_Pair_Int :: Program
fst = [program|
fst = \tuple ->
case tuple of
Pair a b -> a;
badPair -> Error_fst badPair
|]
snd = [program|
snd = \tuple ->
case tuple of
Pair a b -> b;
badPair -> Error_snd badPair
|]
curry = [program|
curry = \f x y ->
let tuple = \(x y) -> Pair x y
in f tuple
|]
uncurry = fst <> snd <> [program|
uncurry = \f tuple ->
let fst' = \(tuple) -> fst tuple;
snd' = \(tuple) -> snd tuple
in f fst' snd'
|]
swap = [program|
swap = \tuple ->
case tuple of
Pair a b -> Pair b a;
badPair -> Error_snd badPair |]
equals_Pair_Int = eq_Int <> [program|
eq_Pair_Int = \tup1 tup2 ->
case tup1 of
Pair a b -> case tup2 of
Pair x y -> case eq_Int a x of
True -> eq_Int b y;
False -> False;
badBool -> Error_eq_Pair badBool;
badPair -> Error_eq_Pair badPair;
badPair -> Error_eq_Pair badPair
|]