[Haskell-cafe] Does an unboxed unit get pushed to the stack?
Tom Ellis
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Thu Jan 12 15:05:56 UTC 2023
On Thu, Jan 12, 2023 at 04:01:48PM +0100, Bertram Felgenhauer via Haskell-Cafe wrote:
> Tom Ellis wrote:
> > If I define bar and baz as below then, as I understand it, calling baz
> > requires pushing an argument onto the machine stack. Is the same true
> > for baz, or is "calling" baz the same as "calling" foo, i.e. no
> > argument needs to be pushed?
> >
> >
> > {-# LANGUAGE MagicHash #-}
> > {-# LANGUAGE UnboxedTuples #-}
> >
> > module Bar where
> >
> > import GHC.Prim
> >
> > foo :: Int
> > foo = 1
> >
> > bar :: (# #) -> Int
> > bar (# #) = 1
> >
> > baz :: () -> Int
> > baz () = 0
>
> There is more to the story than just arguments. Assuming that nothing
> gets inlined
Very helpful, thank you!
More information about the Haskell-Cafe
mailing list