module Err where

import qualified Prelude

-- last is used as background knowledge. This is not useful at all, but triggers
-- the error this test is for.
last :: [a] -> a
last [x]    = x
last (x:xs) = last xs

-- These are IO examples for an automatic bidirectionalization (on lists): given
-- a function get :: [a] -> a (in this case, get = last), look for
-- a corresponding put function. These examples are taken from the GetPut law:
--   put s (get s) = s      (GetPut)
-- Variables occuring in both s and get s are renamed in the first parameter, to
-- allow for changes after get-ing to reflect in the result of put.
put_last :: [a] -> a -> [a]
put_last [a']           a = [a]
put_last [a, b']        b = [a, b]
put_last [a, b, c']     c = [a, b, c]
put_last [a, b, c, d']  d = [a, b, c, d]
