Skip to content
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

Experiment with different pointer primitives #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

buggymcbugfix
Copy link
Member

@buggymcbugfix buggymcbugfix commented Jun 24, 2019

@buggymcbugfix
Copy link
Member Author

buggymcbugfix commented Jun 25, 2019

Reminder to self

Prelude> import Foreign.Marshal.Alloc
Prelude Foreign.Marshal.Alloc> :t malloc
malloc :: Foreign.Storable.Storable a => IO (GHC.Ptr.Ptr a)
Prelude Foreign.Marshal.Alloc> p <- malloc @Int
Prelude Foreign.Marshal.Alloc> import Foreign.Ptr
Prelude Foreign.Marshal.Alloc Foreign.Ptr> import Foreign.Storable
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> poke p 0
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> peek p
0
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> let p2 = castPtr @Int @Bool p
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> peek p2
False
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> poke p 1
Prelude Foreign.Marshal.Alloc Foreign.Ptr Foreign.Storable> peek p2
True

@dorchard dorchard changed the base branch from master to dev-minor October 30, 2019 10:55
@dorchard
Copy link
Member

Okay this is now up to date with dev-minor and I started on the evaluator implementation, however I quickly realised that we really need Ben's interfaces/type-classes merged as well so that we can restrict the types of things that can go inside pointers. We don't want to allow arbitrary things (like functions or suspended effectful computations!) Another alternative is that we restrict the pointers just to integers at the moment.
So this remains in flux.

@buggymcbugfix buggymcbugfix changed the base branch from dev-minor to main May 3, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants