0

I'm trying to store a function type in a definition so I can reuse it, but Haskell doesn't let me do it. A function type is not a data type , nor a class, as far as I understand them. So what am I doing wrong please?

functionType = Int -> Int -> Int -> Int -> Int -> Int -> Int myfunction :: functionType -- <-- how do I declare this thing in a definition? myfunction a b c d e f = a*b*c*d*e*f 
2
  • 9
    type FunctionType = Int -> Int -> Int -> Int -> Int -> Int -> Int Commented Sep 4, 2022 at 9:34
  • 4
    Also note that type-level identifiers must start with an Uppercase Letter. Commented Sep 4, 2022 at 9:49

1 Answer 1

1

Type aliases use the type keyword in their declaration; also, as usual for the declaration of new type forms, the newly declared alias must start with an upper case letter*. So:

type FunctionType = Int -> Int -- -> ... functionValue :: FunctionType functionValue a = a 

* ...or punctuation. Why doesn't the usual "upper-case" punctuation restriction apply? No idea. I never thought about it before trying to write this answer, and now that I have, I find that a bit weird. Perhaps the upper-case restriction on the declaration of new types should be removed!

Sign up to request clarification or add additional context in comments.

2 Comments

"Upper case punctuation" restriction used to be there and was lifted. I want to say somewhere around ghc 6.12
@luqui It makes sense to lift it -- since there is no pattern matching at the type level, the compiler cares less about easily distinguishing variables and constructors. If there's anything nonsensical, it's that the "upper case lettters" restriction wasn't lifted at the same time!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.