Skip to content

Commit

Permalink
Simplify 'seq' for performance (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
utdemir authored Jun 10, 2021
1 parent 2c4f995 commit 5317854
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Prelude/Linear/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- | This is a very very simple prelude, which doesn't depend on anything else
-- in the linear-base library (except possibly "Unsafe.Linear").
-- in the linear-base library.

{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE LambdaCase #-}
Expand All @@ -9,8 +9,6 @@

module Prelude.Linear.Internal where

import qualified Prelude as Prelude
import qualified Unsafe.Linear as Unsafe
import Data.Functor.Identity

-- A note on implementation: to avoid silly mistakes, very easy functions are
Expand Down Expand Up @@ -41,7 +39,7 @@ asTypeOf = const
-- to consume @x@ when the resulting computation is consumed. Therefore, @seq@
-- cannot be linear in it's first argument.
seq :: a -> b %q-> b
seq x y = Unsafe.toLinear (Prelude.seq x) y
seq !_ y = y

($!) :: (a %p-> b) %q-> a %p-> b
($!) f !a = f a
Expand Down

0 comments on commit 5317854

Please sign in to comment.