Skip to content

Reading from buffers should require Eff #5

@hdgarrood

Description

@hdgarrood

Consider the following program:

module Main where

import Prelude
import qualified Node.Buffer as B
import Control.Monad.Eff.Console (log)

main = do
  let buf = B.fromArray [0]
  let x = B.read B.UInt8 0 buf
  B.write B.UInt8 1 0 buf
  let y = B.read B.UInt8 0 buf

  log ("x = " ++ show x)
  log ("y = " ++ show y)

Output:

x = 0
y = 1

This seems to be a subversion of the type system. I think we should require Eff to read or write from a buffer. Since they can be used in a similar way to IORef in Haskell, perhaps we also should require Eff to create them, like Haskell does.

(Unfortunately this program doesn't actually run at the moment but that problem is fixed by #4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions