1

So i heard you can use denotational semantics to write Haskell code using math notation for example circle in place of . to denote function composition. My question is in four parts:

  1. how do I use/write this into my code?
  2. how is the conversion between the two handled?
  3. does this come with time or security concerns?
  4. does this still compile to plutus-core correctly?

1 Answer 1

2

By using . you are already using denotational semantic

In computer science, denotational semantics (initially known as mathematical semantics or Scott–Strachey semantics) is an approach of formalizing the meanings of programming languages by constructing mathematical objects

(source)

in fact the . aims to emulate the function composition operator in math ( , used as g  ∘  f to indicate a function that acts as g(f(x)) ).

with that being said there are still your question to answer to:

how do I use/write this into my code?

in Haskell is as simple as:

circle :: ( b -> c ) -> ( a -> b ) -> ( a -> c )
circle = (.)

how is the conversion between the two handled?

being Haskell lazy-evaluated, when you get to the point of calling

circle g f

it will be substituted to

(.) g f

which is equivalent to

g . f

does this come with time or security concerns?

no security concerns, this is all handled by haskell.

does this still compile to plutus-core correctly?

as long it is {-# INLINEABLE circle #-} it doesn't comes to my mind a reason why it wouldn't

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.