Created
May 31, 2021 16:02
-
-
Save haskie-lambda/b095c6a687eb07d964221129eba14546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prelude> :set -XGADTs | |
Prelude> :set -XEmptyDataDecls | |
Prelude> :{ | |
Prelude| data List l a where | |
Prelude| Nil :: List Empty a | |
Prelude| (:-) :: a -> List l a -> List NE a | |
Prelude| :} | |
Prelude> | |
Prelude> :set -XStandaloneDeriving | |
Prelude> deriving instance (Show a) => Show (List l a) | |
Prelude> (12::Int) :- ((13::Int) :- Nil) | |
(:-) 12 ((:-) 13 Nil) | |
Prelude> import Unsafe.Coerce | |
Prelude Unsafe.Coerce> let indexedAs = (12::Int) :- ((13::Int) :- Nil) | |
Prelude Unsafe.Coerce> unsafeCoerce indexedAs :: [Int] | |
[12,13] | |
Prelude Unsafe.Coerce> let indexedAs = (Nil :: List Empty Int) | |
Prelude Unsafe.Coerce> unsafeCoerce indexedAs :: [Int] | |
[] | |
Prelude Unsafe.Coerce> let indexedErrs = (12::Int) :- ((undefined::Int) :- Nil) | |
Prelude Unsafe.Coerce> unsafeCoerce indexedAs :: [Int] | |
Prelude Unsafe.Coerce> head $ (unsafeCoerce indexedErrs :: [Int]) | |
12 | |
Prelude Unsafe.Coerce> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment