Skip to content

Instantly share code, notes, and snippets.

@guibou
Created June 2, 2021 17:56
Show Gist options
  • Select an option

  • Save guibou/813c278ca5ca72e4fa0d84d75e5324ef to your computer and use it in GitHub Desktop.

Select an option

Save guibou/813c278ca5ca72e4fa0d84d75e5324ef to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Word
data family Address arch
type family InterpreterState arch
type family State arch :: (* -> *) -> *
data instance Address Int = AddressInt Int
data instance Address Char = AddressChar Word8 Word8 Word8 Word8
class Mem8 arch where
store :: Address arch -> f Word8 -> State arch f -> State arch f
load :: Address arch -> State arch f -> Maybe (f Word8)
localhost = AddressChar 127 0 0 1
localhost' = AddressInt 0xff000001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment