-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "un-rolling" a list type. #6165
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ import GHC.TypeLits qualified as GHC | |
import PlutusTx.Blueprint.Class (HasSchema) | ||
import PlutusTx.Blueprint.Definition.Id as DefinitionId (AsDefinitionId (..)) | ||
import PlutusTx.Blueprint.Definition.Internal (Definitions (..), addDefinition, definition) | ||
import PlutusTx.Builtins.Internal (BuiltinByteString, BuiltinData, BuiltinList, BuiltinString, | ||
BuiltinUnit) | ||
import PlutusTx.Builtins.Internal (BuiltinByteString, BuiltinData, BuiltinList, BuiltinPair, | ||
BuiltinString, BuiltinUnit) | ||
|
||
---------------------------------------------------------------------------------------------------- | ||
-- Functionality to "unroll" types. -- For more context see Note ["Unrolling" types] ----------- | ||
|
@@ -89,8 +89,12 @@ type family Unroll (p :: Type) :: [Type] where | |
Unroll BuiltinData = '[BuiltinData] | ||
Unroll BuiltinUnit = '[BuiltinUnit] | ||
Unroll BuiltinString = '[BuiltinString] | ||
Unroll (BuiltinList a) = Prepend (BuiltinList a) (GUnroll (Rep a)) | ||
Unroll (BuiltinList a) = Unroll a | ||
Unroll (BuiltinPair a b) = Unroll a ++ Unroll b | ||
Unroll BuiltinByteString = '[BuiltinByteString] | ||
Unroll [a] = Unroll a | ||
Unroll (a, b) = Unroll a ++ Unroll b | ||
Unroll (Maybe a) = Unroll a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well I still have no idea why this is desired rather than the Sorry for being useless! Maybe the reviewers of the original blueprint PR would know better, CC'ing @kwxm @zliu41. |
||
Unroll p = Prepend p (GUnroll (Break (NoGeneric p) (Rep p))) | ||
|
||
-- | Detect stuck type family: https://blog.csongor.co.uk/report-stuck-families/#custom-type-errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this violate the invariant that the result needs to contain the original type as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a test showing that original type is indeed contained in the un-rolling. The RHS
Unroll a
will make sure thata
is added to the un-rolling, as long as its not a list itself.