Is it possible to do the following:
foo = bar where type A = (Some, Huge, Type, Sig) meh :: A -> (A, A) -> A
I need to use this custom type inside the where clause, so it makes no sense to define it globally.
It's impossible. Why not just define it over a function? You do not need to export it from the module (just use the explicit export list).
By the way, if you really have a large type, this is probably a sign that you should consider it in smaller parts, especially if you have many tuples, as your example suggests; data types will be more appropriate.
Actually, there is one, a little ridiculous way to approach this:
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} foo :: forall abbrv. (abbrv ~ (Some, Huge, Type, Sig)) => abbrv -> abbrv foo x = meh x (x, x) where meh :: abbrv -> (abbrv, abbrv) -> abbrv meh xy = {- ... -}
I cannot recommend the inclusion of two language extensions just for the sake of reducing types in signatures, although if you are already using them (or GADT instead of type families), I believe that it will do no harm.
Caring aside, you should consider how to reorganize your types in cases like ehird suggests.
Source: https://habr.com/ru/post/905722/More articles:jquery get the specific class name of an element that has several assigned classes - javascriptRemoving PDF Text Using iText - itextHow do I tell Googlebot to skip part of the HTML? - htmluser's working directory: XP vs Vista - javaChanging the background of a hover window during debugging on Eclipse - debuggingProtected member warning in a private class (singleton class) - c #start mongodb and return to the terminal - mongodbStore grep output containing spaces in an array - arraysGHC / FFI: the haskell module is called, which imports the haskell libraries from C - cIValueConverter does not work for SolidColorBrush - data-bindingAll Articles