tilia-0.2.0.0: corpora/vendored/comment/declaration/comment-after-a-keyword-that-begins-a-declaration.hs
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE NamedDefaults #-}
{-# LANGUAGE PatternSynonyms #-}
module Loom.Shuttle where
import Data.String (IsString (..))
pattern -- the empty bobbin
Empty :: Bobbin
pattern -- one turn
Empty = Bobbin 0
pattern
-- a full bobbin
Full :: Bobbin
pattern
-- as many turns as it holds
Full = Bobbin 64
default -- threads are named by strings
IsString (String)
class Wound a where
turns :: a -> Int
default -- counted one at a time
turns :: (Show a) => a -> Int
turns = length . show
foreign import -- the motor
ccall "spin" spin :: Int -> IO ()
foreign -- reported to the controller
export ccall reel :: Int -> IO ()
foreign import
-- blocks until the shuttle stops
ccall unsafe "halt" halt :: IO ()
reel :: Int -> IO ()
reel = spin
wind :: Int %1 -> Int
wind n = let %1 -- moved, not copied
m = n in m
{-# INLINE -- small enough
wind #-}
newtype Bobbin = Bobbin Int